You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Angular 21 new unit test builder with Karma and zone.js #32905
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?
I am the author of the linked Stack Overflow question & answer, and I have just updated my answer to include a workaround for the unit-test builder. Please check it out.
@json-derulo My experience is that using the new builder does not require additional setup. Did you have any issues with that?
My intention was to highlight possible documentation and/or migration shortcomings, furthermore to ask about the possibility of global test setup with the new builder.
Thanks for the clarification, @szape89. My goal was mainly to point out
some gaps in the documentation and migration notes, especially regarding
where to place global test setup with the new unit-test builder.
Activity
json-derulo commentedon Apr 9, 2026
I am the author of the linked Stack Overflow question & answer, and I have just updated my answer to include a workaround for the unit-test builder. Please check it out.
szape89 commentedon Apr 10, 2026
@json-derulo My experience is that using the new builder does not require additional setup. Did you have any issues with that?
My intention was to highlight possible documentation and/or migration shortcomings, furthermore to ask about the possibility of global test setup with the new builder.
emilycarter6561-byte commentedon Apr 11, 2026