Angular 21 new unit test builder with Karma and zone.js
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- angular, typescript
- 领域
- build-system, testing
调研方向
从 packages/angular/build/src/builders/unit-test/runners/karma/executor.ts 开始,比较 angular.json 中 Angular 20 和 21 的 unit-test builder 配置。阅读报告中链接的测试迁移文档,并追踪 Karma 如何处理全局测试设置。当预期的 Karma 配置建立完成,并且文档或迁移行为涵盖所报告的升级路径时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Command
test
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
20
Description
After upgrading from Angular 20 to 21, I ran into NGXXXX errors when running unit tests still with Karma and zone.js.
I found a closed issue and a supposed fix for it, but that did not resolve the issue.
Others experienced the same and implemented workarounds which actually do work: StackOverflow, Reddit.
I found that the solution could be that the angular.json has to be modified to be in line with the new project template like this:
- change
"builder": "@angular/build:karma" to"builder": "@angular/build:unit-test" - add
"runner": "karma" - remove the rest of the properties (according to documentation these derive from the development configuration)
I did not find anything regarding the necessity of this change in the documentation, but if that is the case, it would be wise to mention it and maybe even add a migration schematic.
Also its not clear what is the alternative for "main": "src/test.ts" which contains global test setup. My guess is that the "setupFiles" property would be the successor (like "karmaConfig" became "runnerConfig"), but that is disabled for Karma.
So my question is: Where should I put global test setup with the new "unit-test" builder when using Karma?
Thanks in advance.
Minimal Reproduction
npm test
Exception or Error
Your Environment
Angular CLI : 21.2.5
Node.js : 24.14.0
Package Manager : npm 11.9.0
Operating System : win32 x64
Anything else relevant?
No response
- 主要语言
- TypeScript
- 星标
- 27k
- 派生
- 11.8k
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 271
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
angular/angular-cli 的其他 Issue
-
Font inlining cache is not created or reused可能已有人在做 @nagahara-naoki 今天认领。 未关闭area: @angular/build
难度 2/5 1-3 小时 新手友好度 82/100
angular/angular-cli#34719 ·
维护者通常 1 天内回复
-
area: @angular/cli
难度 3/5 半天 新手友好度 42/100
angular/angular-cli#34716 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 72/100
angular/angular-cli#34688 ·
维护者通常 1 天内回复
-
`ng generate application` produces a missing stylesheet when a workspace component type is configured可能已有人在做 @nagahara-naoki 于 3 天前认领。 未关闭area: @schematics/angular
难度 2/5 1-3 小时 新手友好度 25/100
angular/angular-cli#34684 ·
维护者通常 1 天内回复
-
area: @angular/build
难度 4/5 3-5 天 新手友好度 55/100
angular/angular-cli#34674 · 2 条评论 ·
维护者通常 1 天内回复
查看 angular/angular-cli 的全部 Issue
相似的 Issue
-
bug parity
难度 2/5 1-3 小时 新手友好度 70/100
WenyuChiou/agent-board#1489 ·
维护者通常 1 天内回复
-
area: bazaar bug complexity: medium
难度 2/5 1-3 小时 新手友好度 74/100
accensa/x402-facilitator-stellar#779 ·
维护者通常 1 天内回复
-
bug good first issue P4 size:S web-ui
难度 2/5 半天 新手友好度 85/100
josephfung/curia#2600 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
cloudflare/partykit#444 ·