我试图编写一个简单的 watch 任务,用于监视我的测试文件,一旦发生更改,就会使用 gulp-jasmine 编译并运行它们。
我的 watch 任务:
gulp.task('watch', function () {
gulp.watch(['tests/**/[^_]*.ts'], gulp.series(['compile_tests', 'test']));
})
以及测试任务:
gulp.task('test', function(){
return gulp.src('tests/**/[^_]*.spec.js')
.pipe(
jasmine().on('error', function(error){
console.log(error);
this.emit('end');
})
);
});
但是,如果测试代码包含错误,例如is not a function
或其他任何错误,监视任务将崩溃,我不得不一遍又一遍地重新启动它。我的错误处理程序甚至没有被调用。那么我该如何正确处理错误?