Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 365
chris Avatar asked Feb 18 '19 09:02

chris


Video Answer


4 Answers

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

browserNoActivityTimeout: 400000
like image 76
Victor Bredihin Avatar answered Oct 22 '22 10:10

Victor Bredihin


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.

like image 5
chris Avatar answered Oct 22 '22 11:10

chris


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 add this to Karma.conf:

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

now it works, hope this will help you

like image 2
Rafał Polak Avatar answered Oct 22 '22 09:10

Rafał Polak


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.

like image 2
tschumann Avatar answered Oct 22 '22 10:10

tschumann