Reputation: 157
I am using gulp-notify
to get notification of passing and failing cucumber steps.
The thing is that I only get notifications when it is failing, not when tests are passing.
No errors are thrown but the terminal shows passing tests, and I don't get any notification.
Here the contents of my Gulpfile.js:
var gulp = require('gulp');
var cucumber = require('gulp-cucumber');
var notify = require('gulp-notify');
gulp.task('cucumber', function() {
gulp.src('*features/*')
.pipe(cucumber({
'steps': '*features/step_definitions/*.js',
'support': '*features/support/*.js'
}))
.on('error', notify.onError({
title: 'Red',
message: 'Your test(s) failed'
}))
.pipe(notify({
title: 'Green',
message: 'All tests passed (you can refactor)'
}));
});
gulp.task('watch', function() {
gulp.watch(['features/**/*.feature', 'features/**/*.js', 'script/**/*.js'], ['cucumber']);
});
gulp.task('default', ['watch']);
Any ideas what I could be missing?
Upvotes: 1
Views: 292
Reputation: 157
I got it working by calling directly cucumberjs
, like this:
const gulp = require('gulp');
const notifier = require('node-notifier');
const path = require('path');
gulp.task('cucumber', function() {
const { exec } = require('child_process');
exec('clear && node_modules/.bin/cucumber-js', (error, stdout, stderr) => {
if (error) {
notifier.notify({
title: 'Red',
message: 'Your test(s) failed',
icon: path.join(__dirname, 'failed.png')
});
} else {
notifier.notify({
title: 'Green',
message: 'All tests passed (you can refactor)',
icon: path.join(__dirname, 'passed.png')
});
}
console.log(stdout);
console.log(stderr);
});
});
gulp.task('watch', function() {
gulp.watch(['features/**/*.js', 'script/**/*.js'], ['cucumber']);
});
gulp.task('default', ['cucumber', 'watch']);
Upvotes: 1