karma: Karma doesn't exit properly when using public api with the finish callback
Using Karma’s server public API with a done callback makes the whole node process “stuck” - there are probably some event listeners that prevent node process from exiting properly. A simple reproduce scenario:
var karma = require('karma').server;
karma.start({
//transports: ['websocket', 'xhr-polling', 'jsonp-polling'],
browsers: ['Chrome'],
frameworks: ['jasmine'],
files: [
'src/**/*.js',
'test/**/*.spec.js'
],
singleRun: true
}, function(karmaExitCode) {
console.log('Karma exited with ', karmaExitCode);
console.log('but the process will never exit...');
});
Interestingly, removing the flash from the list of transports make the Karma exit after a while (~20s after test are finished on my machine).
There is a small repo with the reproduce scenario here: https://github.com/karma-runner/gulp-karma/blob/exit_pb/exitTest.js I will be digging into the topic but any help from someone more knowledgeable about Karma internals would be highly appreciated.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 16 (7 by maintainers)
process.exit()is fatal, so that won’t work.As a workaround, I am forcing the karma server to be executed in a separate process via ‘gulp-multi-process’
In addition my karma config has autoWatch off, and singleRun on. Hence, I am using gulp to watch my files and delegating all the test tasks (including report generation) to karma.