From 23650473ea7f4b493f119ac9f8e403b165440242 Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Sun, 31 Jul 2022 15:29:16 +0300 Subject: [PATCH] feat: don't reset modules with --no-isolate --- packages/vitest/src/runtime/entry.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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