2015-04-18 15:21:34 +02:00
|
|
|
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 () {
|
2019-07-28 14:57:52 +02:00
|
|
|
var output = document.getElementById('status');
|
2015-04-18 15:21:34 +02:00
|
|
|
if (!output) { return false; }
|
2019-07-28 14:57:52 +02:00
|
|
|
return (/^(\d+ failures?|all passed)/i).test(output.innerText);
|
2015-04-18 15:21:34 +02:00
|
|
|
});
|
|
|
|
}, function () {
|
|
|
|
var failed = page.evaluate(function () { return window.failed; });
|
|
|
|
var output = page.evaluate(function () {
|
2019-07-28 14:57:52 +02:00
|
|
|
return document.getElementById('output').innerText + "\n" +
|
|
|
|
document.getElementById('status').innerText;
|
2015-04-18 15:21:34 +02:00
|
|
|
});
|
|
|
|
console.log(output);
|
|
|
|
phantom.exit(failed > 0 ? 1 : 0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
function waitFor (test, cb) {
|
|
|
|
if (test()) {
|
|
|
|
cb();
|
|
|
|
} else {
|
|
|
|
setTimeout(function () { waitFor(test, cb); }, 250);
|
|
|
|
}
|
2019-07-28 14:57:52 +02:00
|
|
|
}
|