1
0
mirror of https://github.com/twitter/twemoji.git synced 2024-11-02 11:30:12 +00:00

Give better error messages if there's a syntax error that prevents tests from running

This commit is contained in:
Nathan Downs 2018-06-04 17:38:30 -07:00
parent fa3371d0a0
commit 0c5cd1a1c5

View File

@ -17,12 +17,13 @@ var
var results = page.evaluate(function() { var results = page.evaluate(function() {
// remove the first node with the total from the following counts // remove the first node with the total from the following counts
var passed = Math.max(0, document.querySelectorAll('.pass').length - 1); var passed = Math.max(0, document.querySelectorAll('.pass').length - 1);
var resultHeader = document.querySelector('#wru strong');
return { return {
// retrieve the total executed tests number // retrieve the total executed tests number
total: ''.concat( total: ''.concat(
passed, passed,
' blocks (', ' blocks (',
document.querySelector('#wru strong').textContent.replace(/\D/g, ''), resultHeader ? resultHeader.textContent.replace(/\D/g, '') : 'no',
' single tests)' ' single tests)'
), ),
passed: passed, passed: passed,
@ -39,7 +40,7 @@ var
console.log('failed: ' + results.failed); console.log('failed: ' + results.failed);
console.log('errored: ' + results.errored); console.log('errored: ' + results.errored);
console.log('- - - - - - - - - -'); console.log('- - - - - - - - - -');
if (0 < results.failed + results.errored) { if (results.passed === 0 || 0 < results.failed + results.errored) {
phantom.exit(1); phantom.exit(1);
} else test(); } else test();
}, 1000); }, 1000);