Angular 21 new unit test builder with Karma and zone.js
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 45/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Calme
- Stack technique
- angular, typescript
- Domaine
- build-system, testing
Piste de recherche
Commencez par packages/angular/build/src/builders/unit-test/runners/karma/executor.ts et comparez la configuration du builder de tests unitaires d’Angular 20 et 21 dans angular.json. Lisez la documentation sur la migration des tests liée dans le rapport et suivez la manière dont Karma gère la configuration globale des tests. C’est terminé lorsque la configuration Karma attendue est établie et que la documentation ou le comportement de migration couvre le chemin de mise à niveau signalé.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- TypeScript
- Étoiles
- 27k
- Forks
- 11.8k
- Merge moyen
- 16 h 35 min
- PR mergées (30 j)
- 176
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de angular/angular-cli
-
Can't use an array of hostnames in --allowedHosts cli parameter in @angular/build:dev-server Ouvertearea: @angular/build gemini-triaged
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
angular/angular-cli#33955 ·
-
area: @angular/cli gemini-triaged
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
angular/angular-cli#33055 · 1 commentaire · 3 réactions ·
-
unit-test: with --coverage, a setup file's hooks reach only the first spec file of each worker Ouvertearea: @angular/build gemini-triaged
Difficulté 4/5 3-5 jours Accessibilité débutants 72/100
angular/angular-cli#34137 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34131 · 1 personne assignée ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34130 · 1 personne assignée ·
Toutes les issues de angular/angular-cli
Issues similaires
-
comp/desktop P3 type/bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 92/100
NousResearch/hermes-agent#118866 ·
-
Browser Waiting for: Product Owner
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
getsentry/sentry-javascript#24577 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
agilepathway/label-checker#640 ·
-
Plugin stuck at "loading" on DSH 0.1.6-alpha.2 — turnTail list slot registration missing options.id Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
-
Add 2021 Cup data to website Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
chrisparsons83/flexspotff#153 ·