Last active
June 1, 2020 14:26
-
-
Save jxm262/789e056717927ad7a9f0 to your computer and use it in GitHub Desktop.
gulp-istanbul-example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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