如何避免在 Angular 测试阶段出现以下问题:Chrome Headless has not capture in 60000 ms, kill

Posted

技术标签:

【中文标题】如何避免在 Angular 测试阶段出现以下问题:Chrome Headless has not capture in 60000 ms, kill【英文标题】:How to avoid in Angular testing phase having the following issue: Chrome Headless have not captured in 60000 ms, killing 【发布时间】:2021-08-28 07:49:27 【问题描述】:

这通常只发生在 Jenkins 中,对我来说,Karma 似乎正在尝试启动测试,而生成捆绑过程正在完成,所以我想知道是否有办法让 Karma 使用现有的捆绑包,或者先生成一个捆绑包,然后使用该捆绑包启动业力。

错误

[2021-06-10T15:51:24.567Z] [Exec Stream Pumper] [INFO] - Generating browser application bundles...
[2021-06-10T15:51:25.504Z] [Exec Stream Pumper] [INFO] 10 06 2021 15:51:25.405:INFO [karma-server]: Karma v6.1.2 server started at http://localhost:9876/
[2021-06-10T15:51:25.504Z] [Exec Stream Pumper] [INFO] 10 06 2021 15:51:25.409:INFO [launcher]: Launching browsers ChromiumHeadless with concurrency unlimited
[2021-06-10T15:51:25.504Z] [Exec Stream Pumper] [INFO] 10 06 2021 15:51:25.423:INFO [launcher]: Starting browser ChromiumHeadless
[2021-06-10T15:52:26.231Z] [Exec Stream Pumper] [INFO] 10 06 2021 15:52:26.168:WARN [launcher]: ChromiumHeadless have not captured in 60000 ms, killing.
[2021-06-10T15:52:33.103Z]  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFi[Exec Stream Pumper] [INFO] 10 06 2021 15:52:32.846:INFO [launcher]: Trying to start ChromiumHeadless again (1/5).
[2021-06-10T15:53:48.835Z] [Exec Stream Pumper] [INFO] 10 06 2021 15:53:47.634:WARN [launcher]: ChromiumHeadless have not captured in 60000 ms, killing.
[2021-06-10T15:53:51.370Z] [Exec Stream Pumper] [INFO] 10 06 2021 15:53:51.295:INFO [launcher]: Trying to start ChromiumHeadless again (2/5).
[2021-06-10T15:54:48.318Z] [Exec Stream Pumper] [INFO] ✔ Browser application bundle generation complete.

我不知道这是否与生成捆绑包需要 3 分钟的事实有关。

package.json

"karma": "~6.1.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"karma-junit-reporter": "^2.0.1",
"karma-spec-reporter": "0.0.32"

【问题讨论】:

【参考方案1】:

这也发生在本地吗?你有多少个单元测试?

尝试更新karma-chrome-launcherkarma 以及package.json

如果它只发生在Jenkins,那么我认为你需要一台在Jenkins 上具有更好 CPU 和更多 RAM 的计算机/代理。

【讨论】:

仅在 Jenkins 上进行 240 次测试 我用不同 Karma 包的版本更新了我的问题 如果只发生在 Jenkins 上,尝试在本地模拟同一台机器,但这很难做到。尝试使用具有更好 CPU 和更多内存的不同 Jenkins 机器/代理,看看是否有帮助。

以上是关于如何避免在 Angular 测试阶段出现以下问题:Chrome Headless has not capture in 60000 ms, kill的主要内容,如果未能解决你的问题,请参考以下文章

如何避免在 Angular 2 中使用非常长的相对路径进行导入?

如何避免在创建用户的Salesforce测试中出现MIXED_DML_OPERATION错误

[Alpha阶段]测试报告

如何有效避免漏测?

我是如何有效的避免测试漏测

三阶段提交如何避免阻塞?