File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
packages/vitest/src/integrations Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,16 @@ function createVitest(): VitestUtils {
168168 let _config : null | ResolvedConfig = null
169169
170170 const workerState = getWorkerState ( )
171+
172+ if ( ! workerState ) {
173+ const errorMsg = 'Vitest failed to access its internal state.'
174+ + '\n\nOne of the following is possible:'
175+ + '\n- "vitest" is imported directly without running "vitest" command'
176+ + '\n- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)'
177+ + '\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n'
178+ throw new Error ( errorMsg )
179+ }
180+
171181 const _timers = new FakeTimers ( {
172182 global : globalThis ,
173183 config : workerState . config . fakeTimers ,
You can’t perform that action at this time.
0 commit comments