Skip to content

Instantly share code, notes, and snippets.

@jxm262
Last active June 1, 2020 14:26
Show Gist options
  • Save jxm262/789e056717927ad7a9f0 to your computer and use it in GitHub Desktop.
Save jxm262/789e056717927ad7a9f0 to your computer and use it in GitHub Desktop.
gulp-istanbul-example
(function () {
var gulp = require('gulp');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
//moved these to functions instead of gulp
function test(cb) {
gulp.src(['test/**/*.js'])
.pipe(istanbul({includeUntested: true})) // Covering files
.pipe(istanbul.hookRequire()) // Force `require` to return covered files
.on('finish', function () {
gulp.src(['test/**/*.js'])
.pipe(mocha())
.pipe(istanbul.writeReports(
{
dir: './coverage',
reporters: ['html', 'lcov', 'json', 'text', 'text-summary', 'cobertura']
})) // Creating the reports after tests runned
.on('end', cb);
});
};
gulp.task('test', function (cb) {
test(cb);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment