10

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?

1 Answer 1

2

Try this way to handle error

 gulp.task('test', function(){
        var j = jasmine({});
        j.on('error',function(e){
            console.log(e);
            j.end();
      });
      return gulp.src('tests/**/[^_]*.spec.js')
          .pipe(j);
    });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.