我试图用gulp运行摩卡,并以前存在配置。 Moch.opts具有以下行。
--timeout 999999
--ui tdd
--full-trace
--recursive
--compilers js:babel-register
如何在此处添加它们:
gulp.task('test', function() {
return gulp.src('sampleTest/*.js', { read: false })
.pipe(mocha());
});
我相信您可以在传递给gulp-mocha
的选项对象上创建属性,也可以将其读取选项文件。就我而言,我不想复制诸如--recursive
或--require test/_init.js
之类的内容,但我确实想覆盖记者,因此我使用以下所示的代码:
gulp.task('test', ['compile'], function() {
return gulp.src([], { read: false })
.pipe(mocha({
opts: 'test/mocha.opts',
reporter: 'min'
}))
.on('error', gutil.log);
});
您可能需要修改此内容,以便它不假定测试文件的默认路径(例如test/*.js
(,但是在我的简单情况下,我什至不需要通过通往摩卡咖啡的路径。我只是在使用Gulp触发它(好像我已经在命令行上运行了诸如mocha --opts test/mocha.opts --reporter min
之类的东西(
选项将直接传递给 mocha 二进制,因此您可以在基于骆驼圈中使用其任何命令行选项表格。这是文档链接
gulp.task('test', ['compile'], function() {
return gulp.src([], { read: false })
.pipe(mocha({
timeout: 999999,
fullTrace: true,
reporter: 'min'
}))
.on('error', gutil.log);
});
在摩卡电话呼叫之后添加settimeout调用
.pipe(mocha(),setTimeout(function() {
}, 999999))