Merge branch 'master' of ssh://git.indexdata.com/home/git/private/mkws
authorMike Taylor <mike@indexdata.com>
Wed, 5 Feb 2014 00:28:53 +0000 (00:28 +0000)
committerMike Taylor <mike@indexdata.com>
Wed, 5 Feb 2014 00:28:53 +0000 (00:28 +0000)
test/Makefile
test/README.txt
test/package.json [new file with mode: 0644]
test/phantom/evaluate.js
test/phantom/screenshot.js

index 5f059cc..bf0f561 100644 (file)
@@ -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"
+
index 6a49092..fb6bfa5 100644 (file)
@@ -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 (file)
index 0000000..ac5366d
--- /dev/null
@@ -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"
+}
index ccf01e4..0cf56f0 100644 (file)
@@ -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
                 };
             }
         })
index 316b03c..ac4de3b 100644 (file)
@@ -27,4 +27,3 @@ page.open(url, function () {
         phantom.exit();
     }, 200);
 });
-