From 4a3c6facb2c77a6ec450cef5822abd86865b9b91 Mon Sep 17 00:00:00 2001 From: Andrea Giammarchi Date: Sun, 15 Mar 2015 17:31:43 +0000 Subject: [PATCH] added phantom tests --- .travis.yml | 3 +-- index.html | 2 +- package.json | 5 +++-- testrunner.js | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 testrunner.js diff --git a/.travis.yml b/.travis.yml index b6c89b3..0fcb9d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: node_js node_js: - - 0.8 - - 0.9 + - 0.10 git: depth: 1 branches: diff --git a/index.html b/index.html index c0c1153..77b34d1 100644 --- a/index.html +++ b/index.html @@ -1,7 +1,7 @@ - wru test + document-register-element test diff --git a/package.json b/package.json index ac3f402..6fb6393 100644 --- a/package.json +++ b/package.json @@ -26,12 +26,13 @@ }, "main": "./build/document-register-element.js", "scripts": { - "test": "node test/.test.js", + "test": "phantomjs testrunner.js", "web": "IP=0.0.0.0 node node_modules/polpetta" }, "devDependencies": { "wru": ">= 0.0.0", "uglify-js": "1.x", - "polpetta": ">= 0.0.0" + "polpetta": ">= 0.0.0", + "phantomjs": ">= 0.0.0" } } diff --git a/testrunner.js b/testrunner.js new file mode 100644 index 0000000..8a3b957 --- /dev/null +++ b/testrunner.js @@ -0,0 +1,38 @@ +console.log('Loading: test.html'); +var page = require('webpage').create(); +var url = 'index.html'; +page.open(url, function (status) { + if (status === 'success') { + setTimeout(function () { + var results = page.evaluate(function() { + // remove the first node with the total from the following counts + var passed = Math.max(0, document.querySelectorAll('.pass').length - 1); + return { + // retrieve the total executed tests number + total: ''.concat( + passed, + ' blocks (', + document.querySelector('#wru strong').textContent.replace(/\D/g, ''), + ' single tests)' + ), + passed: passed, + failed: Math.max(0, document.querySelectorAll('.fail').length - 1), + errored: Math.max(0, document.querySelectorAll('.error').length - 1) + }; + }); + console.log('- - - - - - - - - -'); + console.log('total: ' + results.total); + console.log('- - - - - - - - - -'); + console.log('passed: ' + results.passed); + console.log('failed: ' + results.failed); + console.log('errored: ' + results.errored); + console.log('- - - - - - - - - -'); + if (0 < results.failed + results.errored) { + status = 'failed'; + } + phantom.exit(0); + }, 2000); + } else { + phantom.exit(1); + } +}); \ No newline at end of file