forked from walf443/js-goban
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_qunit.js
26 lines (25 loc) · 866 Bytes
/
run_qunit.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
// http://code.google.com/p/phantomjs/wiki/ServiceIntegration
if (phantom.state.length === 0) {
if (phantom.args.length === 0 || phantom.args.length > 2) {
console.log('Usage: run-qunit.js URL');
phantom.exit();
} else {
phantom.state = 'run-qunit';
phantom.open(phantom.args[0]);
}
} else {
setInterval(function() {
var el = document.getElementById('qunit-testresult');
if (phantom.state !== 'finish') {
if (el && el.innerText.match('completed')) {
phantom.state = 'finish';
console.log(el.innerText);
try {
failed = el.getElementsByClassName('failed')[0].innerHTML;
} catch (e) {
}
phantom.exit((parseInt(failed, 10) > 0) ? 1 : 0);
}
}
}, 100);
}