[英]Gulp notify not working on successful cucumber steps
I am using gulp-notify
to get notification of passing and failing cucumber steps.我正在使用
gulp-notify
来获取通过和失败的黄瓜步骤的通知。
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:这里是我的 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?任何想法我可能会错过什么?
I got it working by calling directly cucumberjs
, like this:我通过直接调用
cucumberjs
让它工作,就像这样:
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']);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.