diff --git a/packages/vitest/src/runtime/entry.ts b/packages/vitest/src/runtime/entry.ts index d08d9ce07409..024bcf6c2810 100644 --- a/packages/vitest/src/runtime/entry.ts +++ b/packages/vitest/src/runtime/entry.ts @@ -47,8 +47,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