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:
Disconnected, because no message in 10000 ms.
I went on to add browserNoActivityTimeout: 0
to my config file.
When I try to run the tests, the browser opens and the console shows the passed test.
SUCCESS
Skipped 0 tests
Why is the browser not being closed? What is it waiting for?
browserNoActivityTimeout
How long will Karma wait for a message from a browser before disconnecting from it (in ms).
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.