我正在使用来自 gulp 的 karma 中的 Chrome 和 Firefox 启动器运行基本的 jasmine 测试。但是我的浏览器之后总是被关闭。无论测试成功或失败,即使在任务和配置中将单次运行指定为 false 之后。
吞咽任务:
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
});
});
业力.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 of 3 成功执行 (0.001 secs / 0.013 secs)
总计: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 of 3 成功执行 (0.001 secs / 0.013 secs)
总计:6 次成功
[11:09:27] 4.52 秒后完成“测试”
进程以代码 0 终止。