2 Fetch a mkws/jasmine based page into node.js, evaluate the page and check if test status
3 This should make it possible to run the test on the command line in jenkins. e.g.:
5 phantomjs evaluate.js https://mkws-dev.indexdata.com/jasmine-local-popup.html
8 var page = require('webpage').create(),
9 system = require('system');
11 if (system.args.length === 1) {
12 console.log('Usage: screenshot.js <some URL>');
15 var url = system.args[1];
22 var run_time = 12; // poll up to seconds
23 page.open(url, function (status) {
24 console.log("fetch " + url + " with status: " + status);
25 console.log("polling MKWS test status...");
28 for (var i = 1; i <= run_time; i++) {
29 setTimeout(function () {
30 var result = page.evaluate(function (s) {
31 // return document.querySelector(s).innerText;
39 if (result.mkws.jasmine_done) {
40 console.log("MKWS tests are successfully done. Hooray!");
48 setTimeout(function () {
49 var error_png = "./mkws-error.png";
50 console.log("MKWS tests failed after " + run_time + " seconds");
51 console.log("keep screenshot in '" + error_png + "'");
53 page.render(error_png);
55 }, (run_time + 1) * 1000);