gulp.task('test', 'Run tests', ['pre-test'], function () { process.env.UNIT_TESTING = true; process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; return gulp.src('src/**/*.spec.js', {read: false}) // gulp-mocha needs filepaths so you can't have any plugins before it .pipe(mocha({reporter: 'spec'})) .pipe(istanbul.writeReports()) // Enforce a coverage of at least 90% .pipe(istanbul.enforceThresholds({thresholds: {global: 80}})); });
function test() { gulp.src(['./test/**/*.js'], { read: false }) .pipe(mocha()) .pipe(istanbul.writeReports({ dir: 'test-coverage/', reportOpts: { dir: 'test-coverage/' }, reporters: ['lcov', 'text', 'text-summary', 'cobertura'] })) .pipe(istanbul.enforceThresholds({ thresholds: { global: 1 } })); return gulp.src('test-coverage/lcov.info') .pipe(coveralls()); }
gulp.task('test', ['lint'], function (cb) { del.sync(['coverage']); return gulp.src(['src/di.js']) .pipe(istanbul({includeUntested: true})) .pipe(istanbul.hookRequire()) .on('end', function () { return gulp.src(['test/di.js']) .pipe(mocha()) .pipe(istanbul.writeReports({ dir: 'coverage', reportOpts: { dir: 'coverage' } })) .pipe(istanbul.enforceThresholds({ thresholds: { global: 98 } })) .on('error', cb); }); });