You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular项目中fit/fdescribe测试不再返回非零退出码问题求助

问题:Jasmine聚焦测试(fdescribe/fit)未返回非零退出码,构建系统未拦截相关PR

我的构建系统没能拦截包含聚焦测试fdescribe/fit()的PR。之前Jasmine运行这类聚焦测试时会返回非零退出码,但近期该功能失效,在新Angular项目中可复现,怀疑和NodeJS v20.10或MacOS有关,求恢复该功能的方案。

复现步骤

  • 创建新Angular应用:npx -p @angular/cli ng new --strict --standalone --routing --style=scss demo-v17
  • 将项目中任意一个默认测试标记为fit

运行输出

~/.../demo-v17 (main *)$ ng test --no-watch
✔ Browser application bundle generation complete.
12 12 2023 09:49:33.067:INFO [karma-server]: Karma v6.4.2 server started at http://localhost:9877/
12 12 2023 09:49:33.069:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
12 12 2023 09:49:33.072:INFO [launcher]: Starting browser Chrome
12 12 2023 09:49:34.328:INFO [Chrome 120.0.0.0 (Mac OS 10.15.7)]: Connected on socket bTNnn02qMyLlZwf8AAAB with id 66356302
Chrome 120.0.0.0 (Mac OS 10.15.7): Executed 1 of 3 (skipped 2) SUCCESS (0.066 secs / 0.058 secs)
Chrome 120.0.0.0 (Mac OS 10.15.7) ERROR
  Some of your tests did a full page reload!
Chrome 120.0.0.0 (Mac OS 10.15.7): Executed 1 of 3 (skipped 2) ERROR (0.066 secs / 0.058 secs)
Chrome 120.0.0.0 (Mac OS 10.15.7) ERROR
Chrome 120.0.0.0 (Mac OS 10.15.7): Executed 1 of 3 (skipped 2) ERROR (0.076 secs / 0.058 secs)
~/.../demo-v17 (main *)$ echo $?
0

注:日志中“ERROR Some of your tests did a full page reload!”是Angular v17默认行为,暂不关注,核心问题是聚焦测试未触发非零退出码。

环境信息

$ ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 17.0.6
Node: 20.10.0
Package Manager: npm 10.2.3
OS: darwin x64

Angular: 17.0.6
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.6
@angular-devkit/build-angular   17.0.6
@angular-devkit/core            17.0.6
@angular-devkit/schematics      17.0.6
@schematics/angular             17.0.6
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.2 

内容的提问来源于stack exchange,提问作者Rob

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 09:19:55