Reputation: 1578
My project (angular 11) has about 350 unit tests which runs OK in local. In Azure CI I get following error very often lately :
Disconnected (0 times) reconnect failed before timeout of 10000ms (ping timeout)
I run tests in CI with :
ng test --no-watch --code-coverage --browsers=ChromeHeadless
My Karma.config.js :
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-coverage'),
require('karma-spec-reporter'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-junit-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false
},
coverageReporter: {
dir: '../coverage',
subdir: '.',
reporters:[
{type: 'cobertura', file : 'cobertura-coverage.xml'},
{type: 'lcovonly'},
{type: 'text-summary'}
],
type : 'cobertura',
},
junitReporter: {
outputDir: require('path').join(__dirname, '..'),
},
reporters: ['progress', 'kjhtml', 'junit', 'spec', 'coverage'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
browserDisconnectTimeout: 10000
});
};
I wonder if there's something wrong in my Karma config? Any idea?
Upvotes: 1
Views: 852
Reputation: 1324
More often than not, dedicated test machines are weaker than local machines, which can cause the browser to take longer to launch or respond. Karma has a lot of problems with this, mostly solved by increasing this parameter
browserDisconnectTimeout: 60000 Current default value: 30000
Also use a headless browser for ci
browsers: ['ChromiumHeadlessNoSandbox'],
customLaunchers: {
ChromiumHeadlessNoSandbox: {
base: 'ChromiumHeadless',
flags: ['--no-sandbox']
}
},
Upvotes: 0