繁体   English   中英

在吞咽测试后,Karma关闭浏览器

[英]Karma closing browsers after gulp test

我正在使用谷歌中的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
    });
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM