samedi 16 janvier 2016

Get the mocha "end" event from gulp

I'm using gulp-mocha with gulp and I'm trying to get a notification when the mocha tests get completed.

This is my gulpfile.js

var gulp = require('gulp');
var mocha = require('gulp-mocha');
var notify = require("gulp-notify");

gulp.task('test', function () {
  return gulp.src(['test/**/*.js'], { read: false })
    .pipe( mocha({ reporter: 'nyan' }))
    .on("error", notify.onError({
      message: 'Error: <%= error.message %>'
    }))
    .on('end', function () {
      notify( "Tests passed" )
    });
});

gulp.task('watch-test', function () {
  gulp.watch(['./**'], ['test']);
});

gulp.task( 'default', [ 'test', 'watch-test'] );

I managed to see the notification on the "error" event, but i couldn't find a way to get the "end" event.

Any idea about how to get it?

Aucun commentaire:

Enregistrer un commentaire