diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ffded2b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +install: + - git submodule update --init --recursive + +script: cd test && phantomjs TestRunner.js diff --git a/test/TestRunner.js b/test/TestRunner.js new file mode 100644 index 0000000..45e6e39 --- /dev/null +++ b/test/TestRunner.js @@ -0,0 +1,29 @@ +// Run tests in PhantomJS +// +// Exits with status code 0 is all tests pass, or 1 if any fail. +// Pipes successful assertions to stdout and errors to stderr +// +// Run with $ phantomjs TestRunner.js +// +var page = require('webpage').create(); +page.open('./test.html', function() { + + // get an array, with as the first element the test strings and second the test results + var testOutput = page.evaluate(function () { + return document.getElementById('test-output').textContent.split('Tests: '); + }); + + var passed = testOutput[0].match(/✔[^✔✘]*/g) || []; + for (var i = 0; i < passed.length; i++) { + console.log(passed[i]); + } + + var failed = testOutput[0].match(/✘[^✔✘]*/g) || []; + for (var j = 0; j < failed.length; j++) { + console.error(failed[j]); + } + + console.log('Tests: ' + testOutput[1]); + phantom.exit(failed.length ? 1 : 0); +}); +