Skip to content

Commit c2fc322

Browse files
committed
fix: improve runner error
1 parent 7b10ab4 commit c2fc322

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/runner/src/suite.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,13 @@ let currentTestFilepath: string
187187

188188
function assert(condition: any, message: string) {
189189
if (!condition) {
190-
throw new Error(`Vitest failed to find ${message}. This is a bug in Vitest. Please, open an issue with reproduction.`)
190+
throw new Error(
191+
`Vitest failed to find ${message}. One of the following is possible:`
192+
+ '\n- "vitest" is imported directly without running "vitest" command'
193+
+ '\n- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)'
194+
+ '\n- "vitest" is imported inside Vite / Vitest config file'
195+
+ '\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n',
196+
)
191197
}
192198
}
193199

0 commit comments

Comments
 (0)