Path: blob/master/web-gui/buildyourownbotnet/assets/js/codemirror/test/phantom_driver.js
1293 views
var page = require('webpage').create();12page.open("http://localhost:3000/test/index.html", function (status) {3if (status != "success") {4console.log("page couldn't be loaded successfully");5phantom.exit(1);6}7waitFor(function () {8return page.evaluate(function () {9var output = document.getElementById('status');10if (!output) { return false; }11return (/^(\d+ failures?|all passed)/i).test(output.innerText);12});13}, function () {14var failed = page.evaluate(function () { return window.failed; });15var output = page.evaluate(function () {16return document.getElementById('output').innerText + "\n" +17document.getElementById('status').innerText;18});19console.log(output);20phantom.exit(failed > 0 ? 1 : 0);21});22});2324function waitFor (test, cb) {25if (test()) {26cb();27} else {28setTimeout(function () { waitFor(test, cb); }, 250);29}30}313233