I'm trying to write simple watch task that will watch my tests files and on change compile them and run using gulp-jasmine.
My watch task:
gulp.task('watch', function () {
gulp.watch(['tests/**/[^_]*.ts'], gulp.series(['compile_tests', 'test']));
})
and the test task:
gulp.task('test', function(){
return gulp.src('tests/**/[^_]*.spec.js')
.pipe(
jasmine().on('error', function(error){
console.log(error);
this.emit('end');
})
);
});
But if tested code contain errors, like is not a function
or whatever, watch task crashes and I have to restart it again and again. My error handler not even being called. So how can I handle errors in proper way?