I'm using gulp-mocha
and gulp-istanbul
to pipe mocha run through to istanbul for coverage collection.
I'm using done(error)
to denote a test fail in mocha test cases.
When all tests pass, istanbul runs coverage collection and produces reports. When, any test fails, instanbul fails to execute.
gulp.task('cov', ['pre-cov'], function () {
return gulp
.src(['test/service/*.js'])
.pipe(mocha({reporter: 'JSON'})
.once('error', () => {
this.emit('end');
})
.once('end', () => {
this.emit('end');
}))
.pipe(istanbul.writeReports({
dir: 'tmp/unit-test-coverage',
reporters: [ 'lcov','text','text-summary'],
reportOpts: { dir: 'tmp/unit-test-coverage'}
}))
.pipe(istanbul.enforceThresholds({
thresholds: { global: 10 }
}))
.on('end', () => {console.log("EXIT");process.exit(1);});
});
I am however emitting an end
event to gulp when there is a mocha test fail/error. But even that is failing to execute the on(end)
callback at gulp.
Seems, I am missing something here, which would allow me to continue onward to the next stage, which I am unable to figure out with mocha or istanbul docs.
-- thanks for the help in advance.