简体   繁体   English

ng 测试中途失败,出现“[karma-server]: UnhandledRejection”

[英]ng test fails midway with "[karma-server]: UnhandledRejection"

Today when I ran ng test on a project I got the following error [karma-server]: UnhandledRejection and the tests stopped midway - "Executed 26 of 1371".今天,当我在一个项目上运行 ng test 时,出现以下错误[karma-server]: UnhandledRejection并且测试在中途停止 - “Executed 26 of 1371”。 Chrome appears and then disappears and the tests stop. Chrome 出现然后消失,测试停止。

Those tests used to run and I have not made any changes to the source code, so I assume it must be something environment specific that got updated - Karma, Chrome, node, some npm package, or maybe a Windows Update.这些测试用于运行,而我没有对源代码进行任何更改,所以我认为它必须是特定环境的更新——Karma、Chrome、节点、一些 npm 包,或者可能是 Windows 更新。 Also, the same tests run on a Jenkins server which runs on Windows Server.此外,在 Windows Server 上运行的 Jenkins 服务器上运行相同的测试。

This is the full error log:这是完整的错误日志:

$ ng test
Your global Angular CLI version (13.1.3) is greater than your local version (10.2.1). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
10% building 2/2 modules 0 active12 07 2022 11:42:56.289:WARN [karma]: No captured browser, open http://localhost:9876/
12 07 2022 11:42:56.299:INFO [karma-server]: Karma v4.4.1 server started at http://0.0.0.0:9876/
12 07 2022 11:42:56.299:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
12 07 2022 11:42:56.309:INFO [launcher]: Starting browser Chrome
12 07 2022 11:43:28.578:WARN [karma]: No captured browser, open http://localhost:9876/
12 07 2022 11:43:28.754:INFO [Chrome 103.0.5060 (Windows 10.0.0)]: Connected on socket R1Sdp2DoCDFDRIRYAAAA with id 72319116
Chrome 103.0.5060 (Windows 10.0.0): Executed 26 of 1371 SUCCESS (0 secs / 0.312 secs)
12 07 2022 11:43:34.087:ERROR [karma-server]: UnhandledRejection

What is causing this error and how can I fix it?是什么导致了这个错误,我该如何解决?

The solution is to downgrade to Node v14 - https://nodejs.org/dist/latest-v14.x/解决方案是降级到 Node v14 - https://nodejs.org/dist/latest-v14.x/

This is because Karma (or at least Karma 4.4.1) is incompatible with Node 15 and above - see https://github.com/karma-runner/karma/issues/3570这是因为 Karma(或至少 Karma 4.4.1)与 Node 15 及更高版本不兼容 - 请参阅https://github.com/karma-runner/karma/issues/3570

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM