diff --git a/scripts/test-parallel.mjs b/scripts/test-parallel.mjs index a98e0b11c3..cfa80dfa87 100644 --- a/scripts/test-parallel.mjs +++ b/scripts/test-parallel.mjs @@ -35,7 +35,10 @@ const isMacOS = process.platform === "darwin" || process.env.RUNNER_OS === "macO const isWindows = process.platform === "win32" || process.env.RUNNER_OS === "Windows"; const isWindowsCi = isCI && isWindows; const nodeMajor = Number.parseInt(process.versions.node.split(".")[0] ?? "", 10); -const supportsVmForks = Number.isFinite(nodeMajor) ? nodeMajor < 24 : true; +// vmForks is a big win for transform/import heavy suites, but Node 24 had +// regressions with Vitest's vm runtime in this repo. Keep it opt-out via +// OPENCLAW_TEST_VM_FORKS=0, and let users force-enable with =1. +const supportsVmForks = Number.isFinite(nodeMajor) ? nodeMajor !== 24 : true; const useVmForks = process.env.OPENCLAW_TEST_VM_FORKS === "1" || (process.env.OPENCLAW_TEST_VM_FORKS !== "0" && !isWindows && supportsVmForks); diff --git a/vitest.config.ts b/vitest.config.ts index f5f35faaa8..7fc32c5c11 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -18,6 +18,9 @@ export default defineConfig({ test: { testTimeout: 120_000, hookTimeout: isWindows ? 180_000 : 120_000, + // Many suites rely on `vi.stubEnv(...)` and expect it to be scoped to the test. + // This is especially important under `pool=vmForks` where env leaks cross-file. + unstubEnvs: true, pool: "forks", maxWorkers: isCI ? ciWorkers : localWorkers, include: ["src/**/*.test.ts", "extensions/**/*.test.ts", "test/format-error.test.ts"],