我正在使用来自gulp的业力中的Chrome和Firefox启动器运行基本的茉莉花测试。但是之后,我的浏览器总是关闭。无论测试是成功还是失败,即使在任务和配置中将单次运行指定为false后也是如此。
Gulp任务:
karma = require('gulp-karma');
gulp.task('test', ['testsSetup'], function() {
// Be sure to return the stream
// NOTE: Using the fake './foobar' so as to run the files
// listed in karma.conf.js INSTEAD of what was passed to
// gulp.src !
return gulp.src('./foobar')
.pipe(karma({
configFile: 'karma.conf.js',
singleRun: false
}))
.on('error', function(err) {
// Make sure failed tests cause gulp to exit non-zero
console.log(err);
//this.emit('end'); //instead of erroring the stream, end it
});
});
karma.conf.js:
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome','Firefox'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
成功测试的gulp输出的最后一部分:
Chrome 43.0.2357(Windows 7 0.0.0):执行3之3成功(0.041秒/0.036秒)
Firefox 38.0.0(Windows 7 0.0.0):执行3之3成功(0.001秒/0.013秒)
总计:6成功
Chrome 43.0.2357(Windows 7 0.0.0):执行3之3成功(0.041秒/0.036秒)
Firefox 38.0.0(Windows 7 0.0.0):执行3之3成功(0.001秒/0.013秒)
总计:6成功
[11:09:27]在4.52秒后完成“测试”
进程以代码0终止。
当您使用gulp-karma时,您传递的参数与您直接传递给karma的参数不同。上面的singleRun参数将被忽略。我将任务更改为以下内容(改为指定一个操作),它可以按您期望的那样工作:
gulp.task('test', ['testsSetup'], function() {
// Be sure to return the stream
// NOTE: Using the fake './foobar' so as to run the files
// listed in karma.conf.js INSTEAD of what was passed to
// gulp.src !
return gulp.src('./foobar')
.pipe(karma({
configFile: 'karma.conf.js',
action: 'watch',
showStack: true
}))
.on('error', function(err) {
// Make sure failed tests cause gulp to exit non-zero
console.log(err);
this.emit('end'); //instead of erroring the stream, end it
});
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句