From: Mike Taylor Date: Wed, 5 Feb 2014 00:28:53 +0000 (+0000) Subject: Merge branch 'master' of ssh://git.indexdata.com/home/git/private/mkws X-Git-Tag: 1.0.0~1518^2 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=4ab46ff791b729ee3b45b38444ede20f0c792334;hp=d12ff23179714aff6b5003f87433412a408bc792;p=mkws-moved-to-github.git Merge branch 'master' of ssh://git.indexdata.com/home/git/private/mkws --- diff --git a/test/Makefile b/test/Makefile index 5f059cc..bf0f561 100644 --- a/test/Makefile +++ b/test/Makefile @@ -49,15 +49,17 @@ screenshot-indexdata: ls -l ${IMAGES} jsbeautifier jsb indent: - for i in ./spec*/*.js ./js/*.js ./phantom/*.js; do \ + for i in package.json ./spec*/*.js ./js/*.js ./phantom/*.js; do \ jsbeautifier -j $$i > $@.tmp && mv -f $@.tmp $$i; \ done -node-modules: node_modules -node_modules: - npm install ${NPM_INSTALL_FLAGS} jQuery xmlhttprequest jsdom request jasmine-node phantomjs +node_modules node-modules: + npm install ${NPM_INSTALL_FLAGS} help: @echo "make [ all | check | clean | distclean ]" @echo " [ phantomjs | screenshot ]" @echo " [ jsbeautifier | node-modules ]" + @echo "" + @echo "DEBUG=1 make phantomjs PHANTOMJS_TIMEOUT=8 PHANTOM_URL=https://mkws-dev.indexdata.com/jasmine-popup.html" + diff --git a/test/README.txt b/test/README.txt index 6a49092..fb6bfa5 100644 --- a/test/README.txt +++ b/test/README.txt @@ -6,7 +6,7 @@ This directory contains the MasterKey Widget Set (MKWS) Test framework. To install (some) prerequisites, run: $ sudo apt-get install npm -$ sudo npm install jasmine-node -g +$ sudo npm install -g To run the tests, run: @@ -18,6 +18,12 @@ Finished in 2.024 seconds 39 tests, 194 assertions, 0 failures, 0 skipped +$ make phantomjs +[ headless jasmine test with console.log() messages + +$ DEBUG=1 make phantomjs PHANTOM_URL=https://mkws-dev.indexdata.com/jasmine-popup.html +[ less debug noise ] + To get a basic help, run: $ make help @@ -26,14 +32,14 @@ File system hierarchy -------------------------------------- ./spec contains *spec.js files ./js jasmine runtime JS lib - -README.txt this file +./phantom scripts for phantomjs tests Documentation --------------------------------------- http://pivotal.github.io/jasmine/ https://github.com/pivotal/jasmine +http://phantomjs.org/ Installation @@ -43,5 +49,5 @@ Installation $ make node-modules -- -Copyright (c) 2013 IndexData ApS. http://indexdata.com -Dec 2013, Wolfram +Copyright (c) 2013-2014 IndexData ApS. http://indexdata.com +Feb 2014, Wolfram diff --git a/test/package.json b/test/package.json new file mode 100644 index 0000000..ac5366d --- /dev/null +++ b/test/package.json @@ -0,0 +1,21 @@ +{ + "name": "MKWS", + "version": "0.9.1", + "license": "IndexData ApS, Copyright (c) 2013-2014", + "contributors": [{ + "name": "Mike Taylor", + "email": "mike@indexdata.com" + }, { + "name": "Wolfram Schneider", + "email": "wosch@indexdata.com" + }], + "devDependencies": { + "jQuery": "*", + "xmlhttprequest": "*", + "jsdom": "*", + "request": "*", + "jasmine-node": "*", + "phantomjs": "*" + }, + "dummy": "EOF" +} diff --git a/test/phantom/evaluate.js b/test/phantom/evaluate.js index ccf01e4..0cf56f0 100644 --- a/test/phantom/evaluate.js +++ b/test/phantom/evaluate.js @@ -76,12 +76,18 @@ page.onAlert = function (msg) { console.log("Alert: " + msg); }; +// display HTTP errors +page.onResourceError = function (resourceError) { + // console.log('phantomjs error code: ' + resourceError.errorCode); + console.log(resourceError.errorString); + phantom.exit(3); +}; page.open(url, function (status) { if (debug >= 1) console.log("fetch " + url + " with status: " + status); if (status != 'success') { - console.log("Failed to fetch page, give up"); + console.log("Failed to fetch page, give up. Network error?"); phantom.exit(1); } @@ -93,11 +99,13 @@ page.open(url, function (status) { if (!window || !window.$ || !window.mkws) { return false; } else { + var passing = window.$(".passingAlert").text() || window.$(".failingAlert").text(); + return { mkws: window.mkws, html: window.$("html").html(), duration: window.$(".duration").text(), - passing: window.$(".passingAlert").text() + passing: passing }; } }) diff --git a/test/phantom/screenshot.js b/test/phantom/screenshot.js index 316b03c..ac4de3b 100644 --- a/test/phantom/screenshot.js +++ b/test/phantom/screenshot.js @@ -27,4 +27,3 @@ page.open(url, function () { phantom.exit(); }, 200); }); -