[英]Why is Karma not receiving a message from the browser after tests execution completes?
A test was failing with: 测试失败:
Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
So I added this.timeout(0)
to it, then I got: 所以我添加了this.timeout(0)
,然后得到了:
Disconnected, because no message in 10000 ms.
I went on to add browserNoActivityTimeout: 0
to my config file. 我继续将browserNoActivityTimeout: 0
添加到我的配置文件中。
When I try to run the tests, the browser opens and the console shows the passed test. 当我尝试运行测试时,浏览器打开,控制台显示通过的测试。
SUCCESS 成功
Skipped 0 tests 跳过0个测试
Why is the browser not being closed? 为什么浏览器没有关闭? What is it waiting for? 还等什么呢?
browserNoActivityTimeout browserNoActivityTimeout
How long will Karma wait for a message from a browser before disconnecting from it (in ms). Karma在断开与浏览器的消息之前要等待多长时间(以毫秒为单位)。
https://github.com/karma-runner/karma/blob/master/docs/config/01-configuration-file.md#browsernoactivitytimeout https://github.com/karma-runner/karma/blob/master/docs/config/01-configuration-file.md#browsernoactivitytimeout
Command: 命令:
karma start --single-run
Config: 配置:
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'}
]
}
};
Five minutes after typing the question, I find the answer. 键入问题五分钟后,我找到了答案。
The entry point "test/karma.js" has code that opens the debug tab and that is probably interrupting somehow Karma. 入口点“ test / karma.js”具有打开调试选项卡的代码,并且可能以某种方式中断了Karma。
window.open('/karma-runner/debug.html', '_blank');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.