Angular 21 new unit test builder with Karma and zone.js

オープン
#32,905 コメント 3 件 リアクション 4 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
angular, typescript

調査の方向性

packages/angular/build/src/builders/unit-test/runners/karma/executor.ts から始め、angular.json にある Angular 20 と 21 の unit-test builder の設定を比較します。報告書にリンクされているテスト移行のドキュメントを読み、Karma がグローバルなテストセットアップをどのように処理するかを追跡します。期待される Karma 設定が確立され、ドキュメントまたは移行動作によって報告されたアップグレードパスが扱われていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

area: @angular/cli gemini-triaged
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
平均マージ
16時間 35分
マージ済み PR(30日)
176

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

angular/angular-cli のほかの issue

angular/angular-cli の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。