简体   繁体   English

Karma 断开连接,因为 10000 毫秒内没有消息

[英]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 .该问题也可以通过将模块编译器选项更改为例如es2015es2015

它对我来说失败了,因为我在我的组件中设置了 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.

相关问题 测试运行失败:断开连接(0 次),因为 30000 毫秒内没有消息 - Test run fails: Disconnected (0 times), because no message in 30000 ms 由于“ ExpressionChangedAfterItHasBeenCheckedError”,业力测试失败 - Karma failing tests because of “ExpressionChangedAfterItHasBeenCheckedError” 浏览器在执行 karma 测试用例时断开连接 - Browser gets disconnected while executing karma test cases 在 x 毫秒超时之前断开连接重新连接失败(传输关闭) - Disconnected reconnect failed before timeout of x ms (transport close) 无法连接到运行时进程,10000 毫秒后超时 - (原因:无法连接到目标:connect ECONNREFUSED 127.0.0.1:9229) - Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:9229) 超时 - 在 jest.setTimout.Timeout 指定的 10000 毫秒超时内不涉及异步回调 - Timout - Async callback was not involved within 10000ms timeout specified by jest.setTimout.Timeout 由于 Angular Karma Jasmine 测试结果,在测试中看不到我的组件 - Can't see my component in Tests because of Angular Karma Jasmine test results Electron-Angular:由于 angular 组件内未定义的 ipcRenderer 导致运行 Karma 错误 - Electron-Angular: Running Karma errors because of undefined ipcRenderer inside angular component ng 测试不起作用 业力无法启动“ChromeHeadless 在 2000 毫秒内没有被杀死,正在发送 SIGKILL。” - ng test not working karma not able to start “ ChromeHeadless was not killed in 2000 ms, sending SIGKILL.” &#39;this&#39; 隐含类型为 &#39;any&#39; 因为它没有使用 jquery 的类型 annotation.ts(2683) 错误消息 - 'this' implicitly has type 'any' because it does not have a type annotation.ts(2683) error message using jquery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM