Catching gulp-mocha errors

You need to ignore ‘error’ and always emit ‘end’ to make ‘gulp.watch’ work.

function handleError(err) {
  console.log(err.toString());
  this.emit('end');
}

gulp.task("test", function() {
  return gulp.src(paths.tests)
    .pipe(mocha({ reporter: "spec" })
    .on("error", handleError));
});

This makes ‘gulp test’ to always return ‘0’ which is problematic for Continuous Integration, but I think we have no choice at this time.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)