[英]Karma Disconnected, because no message in 10000 ms
The Karma test suite fails with the message: Karma 测试套件失败并显示以下消息:
Disconnected, because no message in 10000 ms.
断开连接,因为在 10000 毫秒内没有消息。
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.失败没有明显的原因,它只是在引入新测试后才开始。
我遇到了同样的问题并尝试了所有方法 - 除了将此选项添加到我的karma.conf.js
之外没有任何效果:
browserNoActivityTimeout: 400000
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.当
tsconfig.spec.json
TypeScript 的--module
编译器选项设置为commonjs
在执行任何测试之前 Karma 在内部失败并显示上面的超时错误。
The import ordering can let Karma fail:导入顺序可能会让 Karma 失败:
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 eg es2015
.该问题也可以通过将模块编译器选项更改为例如
es2015
来es2015
。
它对我来说失败了,因为我在我的组件中设置了 window.location.href,但是测试运行只是在随机时间挂起,而不是在我的组件测试中失败。
I had a similar problem on Chrome 85.0.4183.我在 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."
我不知道为什么 Karma 与浏览器的连接断开,我收到“断开连接,因为 30000 毫秒内没有消息”。
I've add this to Karma.conf:我已将此添加到 Karma.conf:
captureTimeout: 210000,
browserDisconnectTolerance: 3,
browserDisconnectTimeout : 210000,
browserNoActivityTimeout : 210000
now it works, hope this will help you现在它有效,希望这会帮助你
查看 karma 的日志,当测试文件中有编译错误时,karma 服务器返回超时错误而不是真正的错误
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
https://stackoverflow.com/a/37969873/1931563
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.