Chrome recently updated on my mac, and I'm now running Chrome 44.0.2403 (Mac OS X 10.10.3) and have Karma v0.13.3. Sometimes all of my tests will run, but they start breaking when the test runner disconnects from Chrome:
Chrome 44.0.2403 (Mac OS X 10.10.3): Executed 14 of 218 SUCCESS (0 secs / 0.248 secs)
23 07 2015 09:49:14.059:WARN [Chrome 44.0.2403 (Mac OS X 10.10.3)]: Disconnected (1 times
Chrome 44.0.2403 (Mac OS X 10.10.3): Executed 14 of 218 DISCONNECTED (10.082 secs / 0.248
Chrome 44.0.2403 (Mac OS X 10.10.3): Executed 15 of 218 DISCONNECTED (10.082 secs / 1.015
Chrome 44.0.2403 (Mac OS X 10.10.3): Executed 16 of 218 DISCONNECTED (10.082 secs / 1.026
Chrome 44.0.2403 (Mac OS X 10.10.3): Executed 17 of 218 DISCONNECTED (10.082 secs / 1.063
Chrome 44.0.2403 (Mac OS X 10.10.3): Executed 18 of 218 DISCONNECTED (10.082 secs / 1.082
Is Chrome in the background or foreground when that happens?
In the background. This typically happens when I make changes to a code or test file in my IDE, causing the test run to fire.
To elaborate, I notice that the tests always seem to go through fine when I launch Karma, but every time a file change happens it starts running the tests and then hangs for a bit, and complains about a browser disconnect.
I'm also using some other components with Karma like code coverage. Here is my config file:
// Karma configuration
// Generated on Thu May 14 2015 15:11:29 GMT-0700 (PDT)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '../..',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
...
(all of my code files here...)
...
'assets/js/tests/*.js',
// templates
'templates/*.html'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'templates/*.html': 'html2js',
'assets/js/app/*.js': 'coverage'
},
coverageReporter: {
type: 'html',
dir: 'jscoverage/'
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'coverage'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};
I'm afraid that this is related to the great power savings on OS X + Chrome, can you try keeping the browser in the foreground (visibility is important) and see if it still happens?
Looks like that does the trick. It hasn't had any issues since I've kept it visible. Thanks!
Also if I quickly bring the browser into the foreground while it hangs the tests complete successfully.
I can attest that I am also experiencing this issue. Focusing the Chrome window during the test run seems to be the only way to get it to complete. I've noticed this does not happen when only running a small number of tests (such as with ddescribe in Jasmine), but happens consistently when running my full unit test suite.
(OSX 10.10.4 + Chrome)
UPDATE:
I had been using Karma 0.12 with Jasmine 1.3. Upgrading to Karma 0.13.3 and Jasmine 2.3.4 seems to have solved the problem.
EDIT: The fix that worked for me was to add browserDisconnectTolerance: 10 to the karma.conf (any number >1 works)
Same issue - but running chrome in the foreground does not help.
Versions:
I've tried:
xdescribeing tests - If I xdescribe any 30 (of our ~1500) tests, the suite passeskarma.conf.coffee:
module.exports = (config) ->
config.set
frameworks: [ "jasmine" ]
files: [...] # ~500 files
exclude: [...]
preprocessors: {
'**/*.js': ['sourcemap']
}
reporters: ['mocha']
mochaReporter:
ignoreSkipped: yes
autowatch: yes
port: 9292
colors: process.platform is 'darwin'
logLevel: config.LOG_INFO
autoWatch: true
reportSlowerThan: 200
browsers: ['Chrome']
browserNoActivityTimeout: 100000
captureTimeout: 60 * 1000
singleRun: true
captureConsole: true
useIframe: false
restartOnFileChange: true
We're using phantomjs now to run the tests anyway so that might also help as a workaround :)
https://github.com/karma-runner/karma-phantomjs-launcher
The solution posted by @bcherny seems to at least suppress the error, but the output is still quite funky:
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 11 of 11 SUCCESS (0.077 secs / 0.015 secs)
Safari 9.0.3 (Mac OS X 10.11.3): Executed 11 of 11 SUCCESS (0.074 secs / 0.012 secs)
Chrome 50.0.2661 (Mac OS X 10.11.3): Executed 11 of 11 SUCCESS (0.075 secs / 0.017 secs)
Firefox 42.0.0 (Mac OS X 10.11.0): Executed 11 of 11 SUCCESS (0.1 secs / 0.011 secs)
TOTAL: 44 SUCCESS
DEBUG [karma]: Run complete, exiting.
DEBUG [launcher]: Disconnecting all browsers
DEBUG [framework.browserify]: cleaning up
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 11 of 11 SUCCESS (0.077 secs / 0.015 secs)
Safari 9.0.3 (Mac OS X 10.11.3): Executed 11 of 11 DISCONNECTED (10.093 secs / 0.012 secs)
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 11 of 11 SUCCESS (0.077 secs / 0.015 secs)
Safari 9.0.3 (Mac OS X 10.11.3): Executed 11 of 11 DISCONNECTED (10.093 secs / 0.012 secs)
Chrome 50.0.2661 (Mac OS X 10.11.3): Executed 11 of 11 DISCONNECTED (10.094 secs / 0.017 secs)
Firefox 42.0.0 (Mac OS X 10.11.0): Executed 11 of 11 SUCCESS (0.1 secs / 0.011 secs)
INFO [karma]: Restarting Chrome 50.0.2661 (Mac OS X 10.11.3) (1 of 10 attempts)
Most helpful comment
EDIT: The fix that worked for me was to add
browserDisconnectTolerance: 10to the karma.conf (any number >1 works)Same issue - but running chrome in the foreground does not help.
Versions:
I've tried:
xdescribeing tests - If Ixdescribeany 30 (of our ~1500) tests, the suite passeskarma.conf.coffee: