sai
sai

Reputation: 1

ng test -code-coverage is throwing Disconnected Reconnect failed before timeout of 2000ms after migrating to ANGULAR 14

This is happening only after upgrading to angular 14. This I have tried.

All the tests are running successfully but at the end I am getting the below error.

Chrome Headless 117.0.5938.132 (Windows 10) ERROR Disconnected reconnect failed before timeout of 2000ms (server shutting down) Chrome Headless 117.0.5938.132 (Windows 10): Executed 90 of 90 SUCCESS (1.522 secs / 1.235 secs) Chrome Headless 117.0.5938.132 (Windows 10) ERROR Chrome Headless 117.0.5938.132 (Windows 10): Executed 90 of 90 SUCCESS (1.522 secs / 1.235 secs) C:\Users\git\apps\testApplication\node_modules\karma-sonarqube-unit-reporter\index.js:121 var suite = suites[browser.id] ^

TypeError: Cannot read property 'manual-123' of null at SonarQubeUnitReporter.onBrowserComplete (C:\Users\git\apps\testApplication\node_modules\karma-sonarqube-unit-reporter\index.js:121:23) at Server. (C:\Users\git\apps\testApplication\node_modules\karma\lib\events.js:40:26) at Server.emit (events.js:387:35) at Timeout._onTimeout (C:\Users\git\apps\testApplication\node_modules\karma\lib\browser.js:117:22) at listOnTimeout (internal/timers.js:557:17) at processTimers (internal/timers.js:500:7)

Versions I have : node:14.17.3 npm: 6.14.13 "karma": "~6.3.17", "karma-chrome-launcher": "~3.1.1", "karma-coverage": "~2.0.3", "karma-jasmine": "~4.0.2", "karma-jasmine-html-reporter": "~1.7.0", "karma-sonarqube-unit-reporter": "~0.0.23",

I already have the the following on karma.config file autoWatch: true, browsers: ['ChromeHeadlessNoSandbox'], Flags: ['--headless', '--disable-gpu', '--no-sandbox']

Tried upgrading the karma packages to the latest version. But no luck. Also Tried adding the followng in karma.config file. but no luck captureTimeout: 210000,browserDisconnectTolerance: 3,browserDisconnectTimeout : 210000,browserNoActivityTimeout : 210000,

Upvotes: 0

Views: 1377

Answers (2)

Jaraxxus
Jaraxxus

Reputation: 136

With more than 2000 tests, I managed to run my test coverage with this config :

karma.conf.js

module.exports = function (config) {
  config.set({
    //...
    captureTimeout: 100000, // Default 60000
    browserDisconnectTimeout : 10000, // Default 2000
    browserDisconnectTolerance : 1, // Default 0
    browserNoActivityTimeout : 60000, // Default 30000
    //...
  });
};

See https://karma-runner.github.io/6.4/config/configuration-file.html for configuration options.

Upvotes: 0

sai
sai

Reputation: 1

I was able to fix this issue. Most of the articles pointed to configs below.

  1. Time-out configs in karma.config captureTimeout: 60000,browserDisconnectTimeout : 10000, browserDisconnectTolerance : 1, browserNoActivityTimeout : 60000,
  2. flags in karma config flags: [ --disable-gpu, --no-sandbox ] But in my case I had all these configs.still got "disconnected reconnect failed before timeout error" on Jenkins and on my local after running all the tests successfully. The Root cause for this issue was a test case in my code that was using deeplink which caused tests to stuck & timeout.

Upvotes: 0

Related Questions