diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2020-03-31 13:06:58 +0200 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2020-03-31 13:06:58 +0200 |
commit | dbbd82579e8ecd3b3f583cb6963120aa7da7d0b2 (patch) | |
tree | 2e41a8e2702f7d558999e80c3b12b9008b5cc179 /gulpfile.js | |
parent | fe75be1cffa2047309358f7d2e05fe9eee96dd96 (diff) | |
download | fosdem-2021-minimalism-presentation-dbbd82579e8ecd3b3f583cb6963120aa7da7d0b2.tar fosdem-2021-minimalism-presentation-dbbd82579e8ecd3b3f583cb6963120aa7da7d0b2.tar.gz |
fix unit tests, use qunit-puppeteer for es6 support
Diffstat (limited to 'gulpfile.js')
-rw-r--r-- | gulpfile.js | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/gulpfile.js b/gulpfile.js index a4d8ca6..8cdab04 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,8 +1,16 @@ +const pkg = require('./package.json') +const path = require('path') +const glob = require('glob') +const colors = require('colors') +const yargs = require('yargs') +const webpack = require('webpack-stream') +const { runQunitPuppeteer, printResultSummary, printFailedTests } = require('node-qunit-puppeteer') + const gulp = require('gulp') +const tap = require('gulp-tap') const zip = require('gulp-zip') const sass = require('gulp-sass') const babel = require('gulp-babel') -const qunit = require('gulp-qunit') const header = require('gulp-header') const eslint = require('gulp-eslint') const uglify = require('gulp-uglify') @@ -10,9 +18,6 @@ const rename = require('gulp-rename') const minify = require('gulp-clean-css') const connect = require('gulp-connect') const autoprefixer = require('gulp-autoprefixer') -const yargs = require('yargs') -const pkg = require('./package.json') -const webpack = require('webpack-stream'); const root = yargs.argv.root || '.' const port = yargs.argv.port || 8000 @@ -33,9 +38,7 @@ const swallowError = function(error) { gulp.task('js', () => gulp.src(['./js/index.js']) .pipe(babel({ presets: ['@babel/preset-env'] })) - .pipe(webpack({ - mode: 'production' - })) + .pipe(webpack({ mode: 'production' })) .on('error', swallowError) .pipe(header(license, {pkg: pkg})) .pipe(rename('reveal.min.js')) @@ -62,10 +65,39 @@ gulp.task('css-core', gulp.series( gulp.task('css', gulp.parallel('css-themes', 'css-core')) +gulp.task('test-qunit', function() { + + let testFiles = glob.sync('test/*.html' ) + + return Promise.all( testFiles.map( filename => { + return new Promise( ( resolve, reject ) => { + runQunitPuppeteer({ + targetUrl: `file://${path.join(__dirname, filename)}`, + timeout: 10000, + redirectConsole: true, + puppeteerArgs: ['--allow-file-access-from-files'] + }) + .then(result => { + console.log(`\n\n${('Testing '+filename+'...').bold.blue}`); + printResultSummary(result, console); + if( result.stats.failed > 0 ) { + printFailedTests(result, console); + } + + resolve(); + }) + .catch(ex => { + console.error(ex); + reject(); + }); + } ) + } ) ) +} ) + gulp.task('test', gulp.series( - () => gulp.src(['./js/**', 'gulpfile.js']).pipe(eslint()).pipe(eslint.format()) - // () => gulp.src(['./test/*.html']).pipe(qunit()) + () => gulp.src(['./js/**', 'gulpfile.js']).pipe(eslint()).pipe(eslint.format()), + 'test-qunit' )) |