1

When running gulp-mocha, if an unhandled error occurs during a test, I'd like that specific test to fail, but the remaining tests to continue. Currently, gulp-mocha halts on the first test which throws an error and outputs the error to the console. I'm running my tests as gulp test, here is my gulp task:

gulp.task("test", ["build"], () => {
    return gulp
        .src("./out/test/*.js", { read: false })
        .pipe(mocha({ reporter: "spec" }))
        .on("error", () => false);
});

If I run my tests directly via mocha ./out/test/, all tests are run regardless of outcome and the errors are shown at the end of the test run. This is what I want.

Josh M.
  • 26,437
  • 24
  • 119
  • 200
  • Your premise is untrue, in the general sense: gulp-mocha does halt on the first failed test. I've used Mocha long enough to know right off the top of my head that Mocha definitely does not halt on the first failed test, but checked with gulp-mocha and found that it lets Mocha behave like it does by default. So your question here is at best incomplete. Please include a [mcve]. In this case it would mean adding a minimum amount of test code that reproduces what you see. – Louis Jan 31 '16 at 13:39
  • The first sentence in my comment above should be amended to read "gulp-mocha does *not* halt on the first failed test." – Louis Feb 01 '16 at 11:01
  • Thanks, I'm looking into my specific case to try to narrow down why this is happening. – Josh M. Feb 01 '16 at 14:29

0 Answers0