gulp-mocha: Gulp process does not end when testing an app

After a success or failure, if there’s still part of the node process running, the gulp process never ends, and to return to the command line, you must CTRL+C out of Gulp.

Shouldn’t gulp kill anything it requires, such as an app for testing?

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 29 (5 by maintainers)

Commits related to this issue

Most upvoted comments

gulp has a doneCallback method to call when all tasks are finished. You can use it.

gulp.doneCallback = function (err) {
  process.exit(err ? 1 : 0);
};

To resolve the original problem in this thread, try:

gulp.task('default', function () {
  return gulp.src('test/**/*_test.js')
    .pipe(mocha())
    .once('end', function () {
      process.exit();
    });
});

I think @meoguru’s solution is better. The problem with @nicholaswyoung’s solution is when you have tasks that chain. gulp-exit is seemingly equivalent to @nicholaswyoung’s solution, and doesn’t work with chained tasks.