From 3548f95f9cb174a3dc4398fdf5da370c802bf55d Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Tue, 13 May 2025 19:11:41 -0400 Subject: [PATCH] fix(@angular/build): setup unit-test polyfills before TestBed init To ensure that Zone.js is fully setup and patched prior to the use of TestBed, the setup file order for the `vitest` runner of the `unit-test` builder has been swapped. This is particularly relevant for `fakeAsync` which has a module level statement that attempts to capture the `Zone` instance. If Zone.js is not setup at that point, fakeAsync will fail to function in tests. --- packages/angular/build/src/builders/unit-test/builder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/angular/build/src/builders/unit-test/builder.ts b/packages/angular/build/src/builders/unit-test/builder.ts index 4a0808f58115..934440eec5b6 100644 --- a/packages/angular/build/src/builders/unit-test/builder.ts +++ b/packages/angular/build/src/builders/unit-test/builder.ts @@ -194,7 +194,7 @@ export async function* execute( // Add setup file entries for TestBed initialization and project polyfills const setupFiles = ['init-testbed.js']; if (buildTargetOptions?.polyfills?.length) { - setupFiles.push('polyfills.js'); + setupFiles.unshift('polyfills.js'); } try {