Skip to content

Instantly share code, notes, and snippets.

@medatech
Created September 24, 2014 10:49
Show Gist options
  • Save medatech/76c6017cf55630b2db08 to your computer and use it in GitHub Desktop.
Save medatech/76c6017cf55630b2db08 to your computer and use it in GitHub Desktop.
An example of code coverage with Gulp
var gulp = require('gulp');
var istanbul = require('gulp-istanbul');
var mocha = require('gulp-mocha');
gulp.task('test', function (cb) {
gulp.src(['lib/**/*.js', 'web.js', 'api.js'])
.pipe(istanbul()) // Covering files
.on('finish', function () {
gulp.src(['test/**/*.js'])
.pipe(mocha())
.pipe(istanbul.writeReports({
dir: './coverage',
reporters: [ 'lcov', 'json', 'text', 'text-summary' ],
reportOpts: { dir: './coverage' }
})) // Creating the reports after tests runned
.on('end', cb);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment