首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么在测试执行完成后,Karma没有收到来自浏览器的消息?

为什么在测试执行完成后,Karma没有收到来自浏览器的消息?
EN

Stack Overflow用户
提问于 2017-01-24 21:32:38
回答 1查看 815关注 0票数 0

一项测试失败的原因是:

代码语言:javascript
复制
Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.

所以我加入了this.timeout(0),然后我得到了:

代码语言:javascript
复制
Disconnected, because no message in 10000 ms.

我继续将browserNoActivityTimeout: 0添加到配置文件中。

当我尝试运行测试时,浏览器将打开,控制台将显示已通过的测试。

成功 跳过0次测试

为什么浏览器没有关闭?它还在等什么?

browserNoActivityTimeout Karma需要等待多久才能从浏览器中断开连接(以ms表示)。 https://github.com/karma-runner/karma/blob/master/docs/config/01-configuration-file.md#browsernoactivitytimeout

命令:

代码语言:javascript
复制
karma start --single-run

Config:

代码语言:javascript
复制
webpackConfig.module.loaders.push({
  test: /\.js$/,
  include: /src/,
  exclude: /node_modules/,
  loader: 'isparta'
});

var karmaConfig = {
  frameworks: ['mocha'],
  browsers: ['Chrome'],
  //browserNoActivityTimeout: 0,
  logLevel: 'INFO',
  //reporters: ['progress', 'coverage-allsources', 'coverage'],
  reporters: ['progress', 'coverage'],
  autoWatch: true,
  files: [
    'test/karma.js'
  ],
  urlRoot: '/karma-runner/',
  preprocessors: {
    'test/karma.js': ['webpack', 'sourcemap']
  },
  webpackMiddleware: {
    stats: 'minimal',
    watchOptions: {
      aggregateTimeout: 300
    }
  },
  webpack: webpackConfig,
  coverageReporter: {
    dir: 'report/coverage',
    include: 'src/**/*.js',
    // Any .js files that are not imported/required need to be added to the 
    // exclude:, otherwise you will get a JS error for
    // 'Unexpected token in esprima.js'.
    // This appears to be a bug with the karma-coverage-allsources repo.
    exclude: 'src/init.js',
    reporters: [
      {'type' : 'cobertura'},
      {'type' : 'html'},
      {'type': 'text-summary'}
    ]
  }
};
EN

回答 1

Stack Overflow用户

发布于 2017-01-24 21:52:42

打完问题五分钟后,我找到了答案。

入口点"test/karma.js“有打开调试选项卡的代码,这可能会以某种方式中断Karma。

代码语言:javascript
复制
window.open('/karma-runner/debug.html', '_blank');
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41839363

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档