-
-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from mislav/headless-tests
Add headless testing & Travis CI support for QUnit
- Loading branch information
Showing
6 changed files
with
84 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
script: script/test | ||
language: node_js | ||
node_js: | ||
- '0.10' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [ -t 1 ]; then | ||
red="$(printf "\033[31m")" | ||
brightred="$(printf "\033[31;1m")" | ||
green="$(printf "\033[32m")" | ||
reset="$(printf "\033[m")" | ||
else | ||
red= | ||
brightred= | ||
green= | ||
reset= | ||
fi | ||
|
||
phantomjs tests/runner.coffee tests/qunit.html | sed -E " | ||
# failure line: | ||
s/^(✘.+)/${red}\\1${reset}/ | ||
# failure details: | ||
s/^( .+)/${brightred}\\1${reset}/ | ||
# success marker: | ||
s/(✔︎)/${green}\\1${reset}/ | ||
" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
QUnit.module("classList.remove"); | ||
|
||
QUnit.test("Removes duplicated instances of class", function(assert) { | ||
var el = document.createElement("p"), cList = el.classList; | ||
el.className = "ho ho ho" | ||
|
||
cList.remove("ho"); | ||
assert.ok(!cList.contains("ho"), "Should remove all instances of 'ho'"); | ||
assert.strictEqual(el.className, "") | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
urls = require('system').args.slice(1) | ||
page = require('webpage').create() | ||
timeout = 3000 | ||
|
||
qunitHooks = -> | ||
window.document.addEventListener 'DOMContentLoaded', -> | ||
for callback in ['log', 'testDone', 'done'] | ||
do (callback) -> | ||
QUnit[callback] (result) -> | ||
window.callPhantom | ||
name: "QUnit.#{callback}" | ||
data: result | ||
|
||
page.onInitialized = -> page.evaluate qunitHooks | ||
|
||
page.onConsoleMessage = (msg) -> console.log msg | ||
|
||
page.onCallback = (event) -> | ||
if event.name is 'QUnit.log' | ||
details = event.data | ||
if details.result is false | ||
console.log "✘ #{details.module}: #{details.name}" | ||
if details.message and details.message isnt "failed" | ||
console.log " #{details.message}" | ||
if "actual" of details | ||
console.log " expected: #{details.expected}" | ||
console.log " actual: #{details.actual}" | ||
else if event.name is 'QUnit.testDone' | ||
result = event.data | ||
unless result.failed | ||
console.log "✔︎ #{result.module}: #{result.name}" | ||
else if event.name is 'QUnit.done' | ||
res = event.data | ||
console.log "#{res.total} tests, #{res.failed} failed. Done in #{res.runtime} ms" | ||
phantom.exit if !res.total or res.failed then 1 else 0 | ||
|
||
for url in urls | ||
page.open url, (status) -> | ||
if status isnt 'success' | ||
console.error "failed opening #{url}: #{status}" | ||
phantom.exit 1 | ||
else | ||
setTimeout -> | ||
console.error "ERROR: Test execution has timed out" | ||
phantom.exit 1 | ||
, timeout |