javascript – 在吞咽测试后关闭浏览器的Karma
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了javascript – 在吞咽测试后关闭浏览器的Karma,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1906字,纯文字阅读大概需要3分钟。
内容图文
![javascript – 在吞咽测试后关闭浏览器的Karma](/upload/InfoBanner/zyjiaocheng/795/375dec9d4aa24b069d2c77e57ee0e9f0.jpg)
我正在使用谷歌中的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
成功测试的最后一部分输出:
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时,你传入的参数与你直接传递给业力的参数不同.
上面的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
});
});
内容总结
以上是互联网集市为您收集整理的javascript – 在吞咽测试后关闭浏览器的Karma全部内容,希望文章能够帮你解决javascript – 在吞咽测试后关闭浏览器的Karma所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。