From: Wolfram Schneider Date: Thu, 30 Jan 2014 22:23:29 +0000 (+0000) Subject: make a screenshot if the test failed X-Git-Tag: 1.0.0~1556 X-Git-Url: http://git.indexdata.com/?p=mkws-moved-to-github.git;a=commitdiff_plain;h=6edb1603c85a803078f40d530f0c29e04aabffdc make a screenshot if the test failed --- diff --git a/test/spec-dev/evaluate.js b/test/spec-dev/evaluate.js index ac4dbe9..be26202 100644 --- a/test/spec-dev/evaluate.js +++ b/test/spec-dev/evaluate.js @@ -24,7 +24,8 @@ page.open(url, function (status) { console.log("fetch " + url + " with status: " + status); console.log("polling MKWS test status..."); - for (var i = 1; i < run_time; i++) { + var r; + for (var i = 1; i <= run_time; i++) { setTimeout(function () { var result = page.evaluate(function (s) { // return document.querySelector(s).innerText; @@ -39,11 +40,17 @@ page.open(url, function (status) { console.log("MKWS tests are successfully done. Hooray!"); phantom.exit(0); } + r = result; }, i * 1000); } + setTimeout(function () { + var error_png = "./mkws-error.png"; console.log("MKWS tests failed after " + run_time + " seconds"); + console.log("keep screenshot in '" + error_png + "'"); + + page.render(error_png); phantom.exit(1); - }, run_time * 1000); + }, (run_time + 1) * 1000); });