From 80e5865ae3400d48b4ee2810e2569cf318f231b9 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Tue, 13 May 2025 12:38:59 -0400 Subject: [PATCH] fix(@angular/build): provide vitest globals in unit-test builder The experimental `unit-test` builder with the `vitest` runner now provides the test APIs also as globals. This increases the potential compatibility for existing karma/jasmine based tests. The initial unit tests within a newly generated application, for instance, now require no changes to execute with the new builder. --- packages/angular/build/src/builders/unit-test/builder.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/angular/build/src/builders/unit-test/builder.ts b/packages/angular/build/src/builders/unit-test/builder.ts index e86895fdf579..aeae8a1cfb77 100644 --- a/packages/angular/build/src/builders/unit-test/builder.ts +++ b/packages/angular/build/src/builders/unit-test/builder.ts @@ -223,6 +223,7 @@ export async function* execute( instance ??= await startVitest('test', undefined /* cliFilters */, undefined /* options */, { test: { root: outputPath, + globals: true, setupFiles, // Use `jsdom` if no browsers are explicitly configured. // `node` is effectively no "environment" and the default.