From 033ccc7e437f2ca8b91e213700ea72f08f373077 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Wed, 2 Apr 2025 14:16:12 +0900 Subject: [PATCH] chore: tweak "vitest" import error message (#7782) --- packages/vitest/src/runtime/utils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/vitest/src/runtime/utils.ts b/packages/vitest/src/runtime/utils.ts index ce46b991d..ccb5a8e95 100644 --- a/packages/vitest/src/runtime/utils.ts +++ b/packages/vitest/src/runtime/utils.ts @@ -14,6 +14,7 @@ export function getWorkerState(): WorkerGlobalState { + '\n\nOne of the following is possible:' + '\n- "vitest" is imported directly without running "vitest" command' + '\n- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)' + + '\n- "vitest" is imported inside Vite / Vitest config file' + '\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n' throw new Error(errorMsg) } -- 2.51.2