-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestrunner.js
32 lines (31 loc) · 1.06 KB
/
testrunner.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
if (true || phantom.state.length === 0) {
if(phantom.args.length === 0 || phantom.args.length > 2) {
console.log("Simple QUnit test runner for phantom.js");
console.log('Usage: testrunner.js url_to_test_file.html');
console.log('Accepts: http://example.com/file.html and file://`pwd`/test.html');
phantom.exit();
} else {
phantom.state = "run-qunit";
phantom.open(phantom.args[0]);
}
} else {
console.log("Running tests");
setInterval(function() {
var result_el = document.getElementById('qunit-testresult');
if(typeof result_el !== 'undefined') {
try {
var passed = result_el.getElementsByClassName('passed')[0].innerHTML;
var total = result_el.getElementsByClassName('total')[0].innerHTML;
var failed = result_el.getElementsByClassName('failed')[0].innerHTML;
} catch(e) {
// SHHHHHH
}
console.log('Passed: '+passed + ', Failed: '+ failed + ' Total: '+ total);
if(parseInt(failed,10) > 0) {
phantom.exit(1);
} else {
phantom.exit(0);
}
}
}, 100);
}