Skip to content

Commit 49ec507

Browse files
committed
Add phantomjs test runner (from https://github.com/jbnicolai/MathBox.js/)
1 parent ff7298b commit 49ec507

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/TestRunner.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Run tests in PhantomJS
2+
//
3+
// Exits with status code 0 is all tests pass, or 1 if any fail.
4+
// Pipes successful assertions to stdout and errors to stderr
5+
//
6+
// Run with $ phantomjs TestRunner.js
7+
//
8+
var page = require('webpage').create();
9+
page.open('./test.html', function() {
10+
11+
// get an array, with as the first element the test strings and second the test results
12+
var testOutput = page.evaluate(function () {
13+
return document.getElementById('test-output').textContent.split('Tests: ');
14+
});
15+
16+
var passed = testOutput[0].match(/[^]*/g) || [];
17+
for (var i = 0; i < passed.length; i++) {
18+
console.log(passed[i]);
19+
}
20+
21+
var failed = testOutput[0].match(/[^]*/g) || [];
22+
for (var j = 0; j < failed.length; j++) {
23+
console.error(failed[j]);
24+
}
25+
26+
console.log('Tests: ' + testOutput[1]);
27+
phantom.exit(failed.length ? 1 : 0);
28+
});

0 commit comments

Comments
 (0)