Command
test
Is this a regression?
The previous version in which this bug was not present was
No response
Description
The experimental @angular/build:unit-test injects zone.js/testing into the polyfills of builder option but only for Vitest. In use runner: 'karma', there are no way to load zone.js/testing for the environment.
https://github.com/angular/angular-cli/blob/main/packages/angular/build/src/builders/unit-test/builder.ts#L114-L116
I think this lines should be moved to the before branching runners. (if(runnerName === 'karma'))
https://github.com/angular/angular-cli/blob/main/packages/angular/build/src/builders/unit-test/builder.ts#L61-L66
Minimal Reproduction
- Use
unit-test builder for ng test
- Use
fakeAsync in tests
- Run
ng test
Exception or Error
Error: zone-testing.js is needed for the fakeAsync() test helper but could not be found.
Please make sure that your environment includes zone.js/testing
at fakeAsync
Your Environment
Angular CLI: 20.0.3
Node: 22.16.0
Package Manager: pnpm 10.12.1
OS: darwin arm64
Angular: 20.0.4
... animations, common, compiler, compiler-cli, core, elements
... forms, platform-browser, platform-browser-dynamic, router
Package Version
------------------------------------------------------
@angular-devkit/architect 0.2000.3
@angular-devkit/core 20.0.3
@angular-devkit/schematics 20.0.3
@angular/build 20.0.3
@angular/cdk 20.0.3
@angular/cli 20.0.3
@schematics/angular 20.0.3
rxjs 7.8.2
typescript 5.8.3
zone.js 0.15.1
Anything else relevant?
No response
Command
test
Is this a regression?
The previous version in which this bug was not present was
No response
Description
The experimental
@angular/build:unit-testinjectszone.js/testinginto thepolyfillsof builder option but only for Vitest. In userunner: 'karma', there are no way to loadzone.js/testingfor the environment.https://github.com/angular/angular-cli/blob/main/packages/angular/build/src/builders/unit-test/builder.ts#L114-L116
I think this lines should be moved to the before branching runners. (
if(runnerName === 'karma'))https://github.com/angular/angular-cli/blob/main/packages/angular/build/src/builders/unit-test/builder.ts#L61-L66
Minimal Reproduction
unit-testbuilder forng testfakeAsyncin testsng testException or Error
Your Environment
Anything else relevant?
No response