Skip to content

@angular/build:unit-test: inject zone.js/testing before karma builder execution #32032

@hamfastgamgee

Description

@hamfastgamgee

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

No response

Description

The fix made for auto-injecting the zone.js/testing polyfill in the karma builder from #30595 seems to have been accidentally reverted when the karma and vitest runners were refactored back in August, so zone.js + karma apps don't work with the unit-test builder right now unless you make a duplicate build target for the unit-test builder to target instead that specifies the testing polyfill as well.

Minimal Reproduction

Create a minimal zone.js app with a single test that relies on Zone using the "unit-test" karma runner. Run ng test. The test fails because the testing polyfill isn't present.

Exception or Error


Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI       : 21.0.2
Angular           : 21.0.3
Node.js           : 22.14.0
Package Manager   : npm 11.6.2
Operating System  : win32 x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 21.0.2            │ ^21.0.2           │
│ @angular/cdk              │ 21.0.2            │ ~21.0.2           │
│ @angular/cli              │ 21.0.2            │ ~21.0.2           │
│ @angular/common           │ 21.0.3            │ ~21.0.3           │
│ @angular/compiler         │ 21.0.3            │ ~21.0.3           │
│ @angular/compiler-cli     │ 21.0.3            │ ~21.0.3           │
│ @angular/core             │ 21.0.3            │ ~21.0.3           │
│ @angular/forms            │ 21.0.3            │ ~21.0.3           │
│ @angular/material         │ 21.0.2            │ ~21.0.2           │
│ @angular/platform-browser │ 21.0.3            │ ~21.0.3           │
│ @angular/router           │ 21.0.3            │ ~21.0.3           │
│ rxjs                      │ 7.8.2             │ ~7.8.2            │
│ typescript                │ 5.9.3             │ ~5.9.3            │
│ zone.js                   │ 0.16.0            │ ~0.16.0           │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions