gulp在mocha中导致超时
项目在 https://github.com/cgcgbcbc/gulp-chroot
代码大致如下
javascript
// test.js // ... 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'); });
这个测试在运行时会超时是为什么呢?
运行测试的命令是
mocha --harmony --harmon-proxies
眨眼时已是未来
9 years, 8 months ago
Answers
来吧,让你high:
it('should work with promise', function(done) {
gulp.chroot('child', function() {
gulp.task('promise', function() {
return gulp.src('test.txt')
.pipe((function() {
var stream = through2.obj(function(file, encode, next) {
console.log('inside promise task');
console.log(process.cwd());
assert.equal(process.cwd(), path.join(__dirname, 'child'));
next();
});
stream.resume();
return stream;
}()))
.pipe(gulp.dest(path.join(__dirname, 'child', '2.txt')));
});
});
gulp.task('sync', ['promise'], function() {
console.log('inside sync');
done();
});
gulp.start('sync');
});
cliff
answered 9 years, 8 months ago