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;
34 duration: window.$(".duration").text(),
35 passing: window.$(".passingAlert").text()
40 if (result.mkws.jasmine_done) {
41 console.log("MKWS tests are successfully done. Hooray!");
42 console.log("duration: " + result.duration);
43 console.log("passing: " + result.passing);
51 setTimeout(function () {
52 var error_png = "./mkws-error.png";
53 console.log("MKWS tests failed after " + run_time + " seconds");
54 console.log("keep screenshot in '" + error_png + "'");
56 page.render(error_png);
58 }, (run_time + 1) * 1000);