angulartypescriptjasminekarma-runnertypescript-namespace

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.


Solution

  • 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.