.on('finish', function () { gulp .src('./traffic_stops/static/js/test/**/test_*.js', {read: false}) .pipe(mocha({ require: [ 'jsdom-global/register' ] })) .pipe(istanbul.writeReports({ dir: './coverage/' , reportOpts: { dir: './coverage/' } , reporters: [ 'text' , 'text-summary' , 'json' , 'html' ] })) .pipe(coverageEnforcer({ thresholds: { statements: 80 , branches: 50 , lines: 15 , functions: 50 } , coverageDirectory: './coverage/' , rootDirectory: '' })) ; })
gulp.task('test', [ 'coverage' ], function (done) { gulp.src('.') .pipe(enforcer({ thresholds: thresholds, coverageDirectory: 'dist/coverage/', rootDirectory: '' })) .on('error', errorHandler) .on('finish', done); });
return cover(function () { gulp.src(gulp.options.paths.test) .pipe(mocha({reporter: 'dot'})) .on('error', testErrorHandler) // handler for mocha error .pipe(size({ title: 'test-cover' })) .pipe(istanbul.writeReports(gulp.options.coverageSettings.coverageDirectory)) .pipe(covEnforcer(gulp.options.coverageSettings)) .on('error', testErrorHandler) // handler for istanbul error .on('end', cb); });
gulp.task('enforce-coverage', ['mocha-server'], function () { var options = { thresholds: { statements: 80, branches: 80, lines: 80, functions: 80 }, coverageDirectory: 'coverage', rootDirectory: process.cwd() }; return gulp.src(globs.js.lib) .pipe(coverageEnforcer(options)); });
.on('end', function() { var options = { thresholds : { statements : 96, branches : 94, lines : 97, functions : 100 }, coverageDirectory : 'coverage', rootDirectory : '' }; return gulp.src('.') .pipe(coverageEnforcer(options)) .on('end', cb); });
gulp.task('enforce-coverage', ['coverage'], function enforceCoverageTask(cb) { var options = { thresholds: { statements: 100, branches: 100, lines: 100, functions: 100 }, coverageDirectory: 'coverage', rootDirectory: '' }; gulp.src('.') .pipe(coverageEnforcer(options)) .on('end', cb); });
gulp.task('pre-push', ['jshint', 'jscs', 'test-coverage'], function() { var coverageEnforcer = require('gulp-istanbul-enforcer'); var options = { thresholds: { statements: 95, branches: 95, lines: 95, functions: 95 }, coverageDirectory: 'coverage', rootDirectory: process.env.PWD }; return gulp.src('.') .pipe(coverageEnforcer(options)); });
gulp.task('test', [ 'lint' ], () => { return gulp.src(testFiles) .pipe(mocha({ reporter: 'spec' , compilers: 'js:babel/register' , istanbul: true })) .pipe(coverageEnforcer({ thresholds: { statements: 100 , branches: 100 , lines: 100 , functions: 100 } , coverageDirectory: 'coverage' , rootDirectory: '' })) })
.on('finish', function (){ // Load tests into mocha gulp.src( [config.tests + '/*_test.js', config.tests + '/**/*_test.js'] ) .pipe( mocha({ reporter: 'spec' }) .on( 'error', handleError ) ) // Create coverage reports .pipe(istanbul.writeReports({ dir: config.root + '/coverage', reporters: ['html', 'lcov', 'text-summary', 'json'], reportOpts: { dir: config.root + '/coverage' } })) // Throw error if coverage thresholds not met .pipe( istanbulEnforcer(enforcerOptions) ) .on( 'error', handleError ) .on( 'end', handleError ); });