Skip to content

feat(@angular/build): support runtime Zone.js detection in Vitest unit test runner#32492

Draft
clydin wants to merge 1 commit intoangular:mainfrom
clydin:vitest/dynamic-zonejs-inclusion
Draft

feat(@angular/build): support runtime Zone.js detection in Vitest unit test runner#32492
clydin wants to merge 1 commit intoangular:mainfrom
clydin:vitest/dynamic-zonejs-inclusion

Conversation

@clydin
Copy link
Member

@clydin clydin commented Feb 13, 2026

This commit improves how the Vitest unit test runner handles Zone.js and its testing polyfills. Previously, the inclusion of provideZoneChangeDetection and zone.js/testing was determined solely by a build-time check for zone.js in the polyfills array.

Now, the runner supports three strategies for zone.js/testing inclusion:

  • none: If zone.js is not installed in the project.
  • static: If zone.js is explicitly included in the polyfills build option.
  • dynamic: If zone.js is installed but not explicitly in polyfills. This uses a runtime check and dynamic import to load testing support if Zone is present.

Additionally, TestBed initialization now dynamically provides ZoneChangeDetection based on the runtime presence of Zone.js, better supporting zoneless applications and implicit Zone.js loading scenarios.

@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: @angular/build labels Feb 13, 2026
…t test runner

This commit improves how the Vitest unit test runner handles Zone.js and its testing polyfills.
Previously, the inclusion of provideZoneChangeDetection and zone.js/testing was determined solely by a build-time check for zone.js in the polyfills array.

Now, the runner supports three strategies for zone.js/testing inclusion:
- none: If zone.js is not installed in the project.
- static: If zone.js is explicitly included in the polyfills build option.
- dynamic: If zone.js is installed but not explicitly in polyfills. This uses a runtime check and dynamic import to load testing support if Zone is present.

Additionally, TestBed initialization now dynamically provides ZoneChangeDetection based on the runtime presence of Zone.js, better supporting zoneless applications and implicit Zone.js loading scenarios.
@clydin clydin force-pushed the vitest/dynamic-zonejs-inclusion branch from c83fb87 to 7e654f5 Compare February 14, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: @angular/build detected: feature PR contains a feature commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant