Reputation: 4175
I have my angular application with more than 5000 test cases.
It has been running ok before I upgraded to Angular 13 and Karma 6.3, Jasmin 3.6
After upgrade, I am getting this error while running "ng test".
Disconnected reconnect failed before timeout of 960000ms (transport close)
This is how my karma config looks like after
const process = require("process");
process.env.CHROME_BIN = require("puppeteer").executablePath();
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma'),
require('karma-junit-reporter')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
reports: ['html', 'lcovonly','text-summary', 'cobertura'],
fixWebpackSourcePaths: true,
},
reporters: ['progress', 'kjhtml','coverage-istanbul'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
// autoWatch: true,
// browsers: ['ChromeHeadless'],
autoWatch: false,
browsers: ['ChromeHeadlessNoSandbox'],
singleRun: true,
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: [
'--no-sandbox',
'--disable-gpu',
'--js-flags=--max-old-space-size=80196',
'--disable-web-security'
],
},
},
browserNoActivityTimeout: 960000,
browserDisconnectTimeout: 960000,
proxies: {
'/assets/': '/base/src/assets/',
},
});
};
And part of package.json
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "^6.3.13",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "^2.0.6",
"karma-jasmine": "~4.0.0",
I have tried almost every github and stackoverflow, and other suggestions, spoken to many experts, but no success.
Upvotes: 6
Views: 8106
Reputation: 21
You can also enter concurrency: 5 inside karma.conf.js
module.exports = function (config) {
config.set({
// other settings...
concurrency: 5, // allow up to 5 browser instances in parallel
// other settings...
});
};
the concurrency value can be changed to control the number of browser instances that can run in parallel during testing
Upvotes: 2
Reputation: 4175
After more readings this is how I solved the problem.
I made sure all all the test package's versions are correctly updated and compaitable with each other.
This is how it looks now,
"jasmine-core": "4.0.1",
"jasmine-spec-reporter": "7.0.0",
"karma": "6.3.17",
"karma-chrome-launcher": "3.1.1",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-jasmine": "4.0.2"
After this, I was able to run all the test cases.
Upvotes: 5