Skip to content
Snippets Groups Projects
Commit 35e89c5e authored by Tim Baumann's avatar Tim Baumann Committed by Marijn Haverbeke
Browse files

Run test suite with PhantomJS and Travis

parent 195b3a7b
No related branches found
No related tags found
No related merge requests found
/node_modules
/npm-debug.log
\ No newline at end of file
language: node_js
node_js:
- 0.8
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
......@@ -12,6 +12,12 @@
"directories": {
"lib": "./lib"
},
"scripts": {
"test": "node ./test/run.js"
},
"devDependencies": {
"node-static": "0.6.0"
},
"bugs": "http://github.com/marijnh/CodeMirror2/issues",
"keywords": ["JavaScript", "CodeMirror", "Editor"],
"homepage": "http://codemirror.net",
......
var page = require('webpage').create();
page.open("http://localhost:3000/test/index.html", function (status) {
if (status != "success") {
console.log("page couldn't be loaded successfully");
phantom.exit(1);
}
waitFor(function () {
return page.evaluate(function () {
var output = document.getElementById('output');
if (!output) { return false; }
return (/(\d+ failures?|all passed)$/i).test(output.innerText);
});
}, function () {
var failed = page.evaluate(function () { return window.failed; });
var output = page.evaluate(function () {
return document.getElementById('output').innerText;
});
console.log(output);
phantom.exit(failed > 0 ? 1 : 0);
});
});
function waitFor (test, cb) {
if (test()) {
cb();
} else {
setTimeout(function () { waitFor(test, cb); }, 250);
}
}
\ No newline at end of file
#!/usr/bin/env node
var files = new (require('node-static').Server)('.');
var server = require('http').createServer(function (req, res) {
req.addListener('end', function () {
files.serve(req, res);
});
}).addListener('error', function (err) {
throw err;
}).listen(3000, function () {
var child_process = require('child_process');
child_process.exec("which phantomjs", function (err) {
if (err) {
console.error("PhantomJS is not installed. Download from http://phantomjs.org");
process.exit(1);
}
var cmd = 'phantomjs test/phantom_driver.js';
child_process.exec(cmd, function (err, stdout) {
server.close();
console.log(stdout);
process.exit(err ? 1 : 0);
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment