首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gulp通知在成功的黄瓜步骤上不起作用

Gulp通知在成功的黄瓜步骤上不起作用
EN

Stack Overflow用户
提问于 2017-10-09 23:14:58
回答 1查看 211关注 0票数 1

我正在使用gulp-notify来获得通过和失败黄瓜步骤的通知。

问题是,我只在失败时收到通知,而不是在测试通过时收到通知。

没有抛出错误,但是终端显示通过测试,并且我没有收到任何通知。

下面是我的Gulpfile.js的内容:

代码语言:javascript
复制
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']);

你知道我会错过什么吗?

EN

回答 1

Stack Overflow用户

发布于 2017-10-10 17:45:51

我通过直接调用cucumberjs让它正常工作,如下所示:

代码语言:javascript
复制
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']);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46649738

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档