Skip to content

Commit 8b2ca7a

Browse files
committed
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.
1 parent 7b8c9af commit 8b2ca7a

File tree

1 file changed

+1
-1
lines changed
  • packages/angular/build/src/builders/unit-test

1 file changed

+1
-1
lines changed

packages/angular/build/src/builders/unit-test/builder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export async function* execute(
194194
// Add setup file entries for TestBed initialization and project polyfills
195195
const setupFiles = ['init-testbed.js'];
196196
if (buildTargetOptions?.polyfills?.length) {
197-
setupFiles.push('polyfills.js');
197+
setupFiles.unshift('polyfills.js');
198198
}
199199

200200
try {

0 commit comments

Comments
 (0)