1
0
mirror of https://github.com/hakimel/reveal.js.git synced 2025-10-26 19:53:23 +01:00

fix unit tests, use qunit-puppeteer for es6 support

This commit is contained in:
Hakim El Hattab
2020-03-31 13:06:58 +02:00
parent fe75be1cff
commit dbbd82579e
6 changed files with 201 additions and 224 deletions

View File

@@ -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'
))