diff --git a/packages/vitest/src/runtime/entry.ts b/packages/vitest/src/runtime/entry.ts index aab9c5d24105..62561c5d3b30 100644 --- a/packages/vitest/src/runtime/entry.ts +++ b/packages/vitest/src/runtime/entry.ts @@ -45,8 +45,13 @@ export async function run(files: string[], config: ResolvedConfig): Promise { for (const file of files) { - workerState.mockMap.clear() - resetModules(workerState.moduleCache, true) + // it doesn't matter if running with --threads + // if running with --no-threads, we usually want to reset everything before running a test + // but we have --isolate option to disable this + if (config.isolate) { + workerState.mockMap.clear() + resetModules(workerState.moduleCache, true) + } workerState.filepath = file