From 2cb3d174ffdfff72054271450f1030f6f3969e06 Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Mon, 12 Oct 2026 11:06:33 +0000 Subject: [PATCH] fix(@angular/build): disable Vitest fsModuleCache in unit-test builder Vitest 5.0.4 enabled `fsModuleCache` by default, which caches transformed modules on disk keyed by the raw source file content on disk before calling Vite's `load()` hook. Because `@angular/build:unit-test` pre-bundles test entry points and their imported application modules into memory, changes to imported application files do not change the on-disk `.spec.ts` file content, causing Vitest's `fsModuleCache` to serve stale cached bundles across test runs. --- .../build/src/builders/unit-test/runners/vitest/plugins.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/angular/build/src/builders/unit-test/runners/vitest/plugins.ts b/packages/angular/build/src/builders/unit-test/runners/vitest/plugins.ts index 6be4c6e8ebe3..ec0cd0a8f269 100644 --- a/packages/angular/build/src/builders/unit-test/runners/vitest/plugins.ts +++ b/packages/angular/build/src/builders/unit-test/runners/vitest/plugins.ts @@ -271,6 +271,7 @@ export async function createVitestConfigPlugin( test: { name: projectName, include, + fsModuleCache: false, // CLI provider browser options override, if present ...(browser ? { browser } : {}), // Only override if the user explicitly set it via CLI @@ -290,6 +291,7 @@ export async function createVitestConfigPlugin( return { test: { + fsModuleCache: false, coverage: await generateCoverageOption( options.coverage, testConfig?.coverage,