Reputation: 121
I am working on a angular application, when I run "ng test" command it shows some error and says 'Disconnected (0 times), because no message in 30000 ms. '. I tried updating karma, jasmine packages and did 'npm install', but still it didn't help any. Here are the dependency packages and karma.conf.js files. Am I missing something here? Any package Upgrade is needed?
"devDependencies": {
"@angular-devkit/build-angular": "~0.13.0",
"@angular/animations": "^5.0.0",
"@angular/cli": "~7.3.2",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "~7.2.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.4.2",
"husky": "^0.13.4",
"jasmine-core": "^2.5.2",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^3.1.4",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2",
"typescript-formatter": "^7.2.2",
"webpack": "^4.9.2"
},
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')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [
{
pattern: 'specs.ts',
included: false
}
],
preprocessors: {
},
mime: {
'text/x-typescript': ['ts', 'tsx']
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, 'coverage'), reports: ['html', 'lcovonly'],
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true,
thresholds: {
statements: 80,
lines: 80,
branches: 80,
functions: 80
}
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'coverage-istanbul']
: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
customLaunchers: {
ChromeHeadlessCI: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
singleRun: false,
restartOnFileChange: true
});
};
Upvotes: 4
Views: 10679
Reputation: 181
Following configuration options in karma.conf.js could help:
module.exports = function (config) {
config.set({
//***
browserNoActivityTimeout: 60000,
browserDisconnectTimeout: 60000
//***
});
};
For example this is helpful when running karma-parallel which starts many browsers and it takes time for all of them to initialize ...
For reference see karma configuration file documentation: https://karma-runner.github.io/4.0/config/configuration-file.html
Upvotes: 7