diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2020-03-31 14:06:38 +0200 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2020-03-31 14:06:38 +0200 |
commit | 881146500c18c2a18582af586e130ceffd66f41c (patch) | |
tree | cdd63b0513b48a0d7080464bdf18aec40264d0d8 /gulpfile.js | |
parent | ca29e3dd29c9f562371cc9ef78a8538aeb4e6466 (diff) | |
download | fosdem-2021-minimalism-presentation-881146500c18c2a18582af586e130ceffd66f41c.tar fosdem-2021-minimalism-presentation-881146500c18c2a18582af586e130ceffd66f41c.tar.gz |
qunit task rejects on failure
Diffstat (limited to 'gulpfile.js')
-rw-r--r-- | gulpfile.js | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/gulpfile.js b/gulpfile.js index ea3f133..ac1429d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -65,7 +65,10 @@ gulp.task('test-qunit', function() { let testFiles = glob.sync('test/*.html' ) - return Promise.all( testFiles.map( filename => { + let totalTests = 0; + let failingTests = 0; + + let tests = Promise.all( testFiles.map( filename => { return new Promise( ( resolve, reject ) => { runQunitPuppeteer({ targetUrl: `file://${path.join(__dirname, filename)}`, @@ -74,20 +77,43 @@ gulp.task('test-qunit', function() { puppeteerArgs: ['--allow-file-access-from-files'] }) .then(result => { - console.log(`\n\n${('Testing '+filename+'...').bold.blue}`); - printResultSummary(result, console); if( result.stats.failed > 0 ) { + console.log(`${'!'} ${filename} [${result.stats.passed}/${result.stats.total}] in ${result.stats.runtime}ms`.red); + // printResultSummary(result, console); printFailedTests(result, console); } + else { + console.log(`${'✔'} ${filename} [${result.stats.passed}/${result.stats.total}] in ${result.stats.runtime}ms`.green); + } + + totalTests += result.stats.total; + failingTests += result.stats.failed; resolve(); }) - .catch(ex => { - console.error(ex); + .catch(error => { + console.error(error); reject(); }); } ) - } ) ) + } ) ); + + return new Promise( ( resolve, reject ) => { + + tests.then( () => { + if( failingTests > 0 ) { + reject( new Error(`${failingTests}/${totalTests} tests failed`.red) ); + } + else { + console.log(`${'✔'} Passed ${totalTests} tests`.green.bold); + resolve(); + } + } ) + .catch( () => { + reject(); + } ); + + } ); } ) gulp.task('test', gulp.series( |