From b0c60daa2bf928a0f96c1214f0ca0b33343fc9fc Mon Sep 17 00:00:00 2001 From: Vladimir Date: Sun, 4 Sep 2022 10:14:07 +0300 Subject: [PATCH] feat!: don't reset modules with --no-isolate (#1754) Co-authored-by: Anthony Fu --- 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 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