2016-02-28 18:22:34 +00:00
|
|
|
var
|
|
|
|
webpage = require('webpage'),
|
|
|
|
urls = [
|
2019-05-29 20:27:56 +00:00
|
|
|
'2/test/index.html'
|
2016-02-28 18:22:34 +00:00
|
|
|
]
|
|
|
|
;
|
|
|
|
|
|
|
|
(function test() {'use strict';
|
|
|
|
var page, url = urls.shift();
|
|
|
|
if (!url) return phantom.exit(0);
|
|
|
|
console.log('Loading: ' + url);
|
|
|
|
page = webpage.create();
|
|
|
|
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);
|
2018-06-05 00:38:30 +00:00
|
|
|
var resultHeader = document.querySelector('#wru strong');
|
2016-02-28 18:22:34 +00:00
|
|
|
return {
|
|
|
|
// retrieve the total executed tests number
|
|
|
|
total: ''.concat(
|
|
|
|
passed,
|
2018-06-05 00:44:42 +00:00
|
|
|
' tests (',
|
2018-06-05 00:38:30 +00:00
|
|
|
resultHeader ? resultHeader.textContent.replace(/\D/g, '') : 'no',
|
2018-06-05 00:44:42 +00:00
|
|
|
' assertions)'
|
2016-02-28 18:22:34 +00:00
|
|
|
),
|
|
|
|
passed: passed,
|
|
|
|
failed: Math.max(0, document.querySelectorAll('.fail').length - 1),
|
|
|
|
errored: Math.max(0, document.querySelectorAll('.error').length - 1)
|
|
|
|
};
|
|
|
|
});
|
|
|
|
page.stop();
|
|
|
|
page.close();
|
|
|
|
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('- - - - - - - - - -');
|
2018-06-05 00:38:30 +00:00
|
|
|
if (results.passed === 0 || 0 < results.failed + results.errored) {
|
2016-02-28 18:22:34 +00:00
|
|
|
phantom.exit(1);
|
|
|
|
} else test();
|
|
|
|
}, 1000);
|
|
|
|
} else phantom.exit(1);
|
|
|
|
});
|
|
|
|
}());
|