From dd35ba2ac11f0bbacaacee5d42263c0c31b11e2a Mon Sep 17 00:00:00 2001 From: Apostolos Mantzaris Date: Mon, 2 Nov 2026 22:54:44 +0200 Subject: [PATCH] fix(test): give the mutation config the per-worktree module cache Verify on #5212 (F5): vitest.mutation.config.ts kept Vitest's default fsModuleCachePath, the shared node_modules/.vitest-cache. A DEBUG run of the campaign config logged 232 shared-cache lines before and 0 after. Refs #5206 Co-Authored-By: Claude Opus 5.5 --- tests/config/module-instance-coverage.test.ts | 4 ++++ tests/config/vitest-cache-root.test.ts | 7 +++++++ vitest.mutation.config.ts | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/config/module-instance-coverage.test.ts b/tests/config/module-instance-coverage.test.ts index e6bf5f200..d4fc3f1b6 100644 --- a/tests/config/module-instance-coverage.test.ts +++ b/tests/config/module-instance-coverage.test.ts @@ -43,6 +43,10 @@ const reviewedExceptions = new Map([ "tests/config/vitest-cache-root.test.ts -> vitest.config.ts", "reads the live config source to verify the cache-root configuration", ], + [ + "tests/config/vitest-cache-root.test.ts -> vitest.mutation.config.ts", + "reads the live mutation config source to verify its cache root", + ], [ "tests/config/worker-budget.test.ts -> vitest.config.ts", "reads the live config source, not the stale compiled vitest.config.js", diff --git a/tests/config/vitest-cache-root.test.ts b/tests/config/vitest-cache-root.test.ts index 0c2605c3c..6a21ef179 100644 --- a/tests/config/vitest-cache-root.test.ts +++ b/tests/config/vitest-cache-root.test.ts @@ -1,6 +1,7 @@ import * as path from "node:path"; import { describe, expect, it } from "vitest"; import vitestConfig, { resolveVitestCacheDir } from "../../vitest.config.ts"; +import mutationConfig from "../../vitest.mutation.config.ts"; describe("Vitest module cache roots (#5206)", () => { it("does not use the linked install's shared cache", () => { @@ -15,6 +16,12 @@ describe("Vitest module cache roots (#5206)", () => { ); }); + it("gives the mutation campaign's config the same per-worktree cache", () => { + expect(mutationConfig.test?.fsModuleCachePath).toBe( + path.join(process.cwd(), ".vitest-cache"), + ); + }); + it("separates cache directories for two worktree roots", () => { // Host path functions: on Windows the roots resolve to a drive letter // and backslashes, so POSIX literals would red the required job. diff --git a/vitest.mutation.config.ts b/vitest.mutation.config.ts index 260b4d891..acc2644ed 100644 --- a/vitest.mutation.config.ts +++ b/vitest.mutation.config.ts @@ -1,5 +1,5 @@ import { defineConfig } from "vitest/config"; -import { sharedGlobalSetup } from "./vitest.config.js"; +import { resolveVitestCacheDir, sharedGlobalSetup } from "./vitest.config.js"; // #4365: the per-test mutation campaign's vitest config. The Stryker vitest // runner forces `pool: "threads"`, which rejects the `execArgv` every project in @@ -14,6 +14,8 @@ export default defineConfig({ test: { include: files.length > 0 ? files : ["tests/no-such-file.test.ts"], globalSetup: sharedGlobalSetup, + // Same per-worktree module cache as vitest.config.ts (#5206). + fsModuleCachePath: resolveVitestCacheDir(process.cwd()), setupFiles: ["./tests/support/vitest-setup.ts"], teardownTimeout: 30_000, },