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 <noreply@anthropic.com>
This commit is contained in:
Apostolos MantzarisandClaude Opus 5.5 committed 2026-11-02 22:54:44 +02:00
1 parent 56cb010663
commit dd35ba2ac1
3 files changed
+14 -1

No files matched your search

@@ -43,6 +43,10 @@ const reviewedExceptions = new Map<string, string>([
"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",
+7
View File
@@ -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.
+3 -1
View File
@@ -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,
},