【问题标题】:run gulp task in mocha test lead to timeout在 mocha 测试中运行 gulp 任务导致超时
【发布时间】:2015-07-26 11:58:52
【问题描述】:

完整代码见here

而失败的测试是:

it('should work with promise', function(done) {
  gulp.chroot('child', function() {
  gulp.task('promise', function() {
    return gulp.src('test.txt')
            .pipe(through2.obj(function(){
              console.log('inside promise task');
              console.log(process.cwd());
              assert.equal(process.cwd(), path.join(__dirname, 'child'));
            }))
            .pipe(gulp.dest(path.join(__dirname, 'child', '2.txt')));
    });
  });
  gulp.task('sync', ['promise'], function() {
    console.log('inside sync');
    done();
  });
  gulp.start('sync');
});

这个测试会超时,为什么?而inside sync 从不打印

【问题讨论】:

  • 这与 ES6 或 Promise 有什么关系?

标签: javascript node.js gulp mocha.js


【解决方案1】:

你的 gulp 任务永远不会到达,所以 done();永远不会到达 - 因此没有回调,它会超时。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-28
    • 2014-09-20
    相关资源
    最近更新 更多