chris
chris

Reputation: 2627

Karma Disconnected, because no message in 10000 ms

The Karma test suite fails with the message:

Disconnected, because no message in 10000 ms.

No tests are executed at all.

"@angular/core": "7.1.3",
"jasmine-core": "3.3.0",
"karma-jasmine": "1.1.2",

There is no apparent reason for the failure, it just started after a new test was introduced.

Upvotes: 19

Views: 40727

Answers (7)

Olha Ivanova
Olha Ivanova

Reputation: 1

In my case after updating basic angular libraries chrome driver started to work properly.

"devDependencies": {
        "@angular-devkit/build-angular": "15.1.1", #was
        "@angular-devkit/build-angular": "^15.2.10", #became
        "@angular/cli": "15.1.1",   #was
        "@angular/cli": "^15.2.10", #became

Upvotes: 0

Rafał Polak
Rafał Polak

Reputation: 61

I had a similar problem on Chrome 85.0.4183. I don't know why Karma lose connection with browser and I get "Disconnected, because of no message in 30000 ms."

I've added this to Karma.conf:

captureTimeout: 210000,
browserDisconnectTolerance: 3, 
browserDisconnectTimeout : 210000,
browserNoActivityTimeout : 210000

now it works, hope this will help you

Upvotes: 6

Abdessattar NOISSI
Abdessattar NOISSI

Reputation: 464

Check the log of karma, when there is a compilation errors in test files, the karma server return as a timeout error and not the real error

Upvotes: 1

tschumann
tschumann

Reputation: 3256

It failed for me because I was setting window.location.href in my component, but the test run just hung at random times rather than failing in the test for my component.

Upvotes: 2

Victor Bredihin
Victor Bredihin

Reputation: 2360

I had the same problem and tried everything - nothing works except adding this option to my karma.conf.js:

browserNoActivityTimeout: 400000

Upvotes: 27

chris
chris

Reputation: 2627

When the --module compiler option for TypeScript in tsconfig.spec.json is set to commonjs Karma fails internally before any tests are executed and shows the timeout error above.

The import ordering can let Karma fail:

import CustomerTypeEnum = CustomerDto.CustomerTypeEnum;
import {CustomerDto} from '../api/CustomerDto';

While this order works as expected:

import {CustomerDto} from '../api/CustomerDto';
import CustomerTypeEnum = CustomerDto.CustomerTypeEnum;

The problem can also be fixed by changing the module compiler option to e.g. es2015.

Upvotes: 6

AlokeT
AlokeT

Reputation: 1216

You can add this where you have need greater time than jasmine default time.

  beforeEach(async(() => {
    jasmine.DEFAULT_TIMEOUT_INTERVAL = <whatever time your test need to complete>;
  }));

and also you can check this answer if this not working. https://stackoverflow.com/a/37969873/1931563

Upvotes: -4

Related Questions