File tree 1 file changed +10
-0
lines changed
packages/vitest/src/integrations
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,16 @@ function createVitest(): VitestUtils {
168
168
let _config : null | ResolvedConfig = null
169
169
170
170
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
+
171
181
const _timers = new FakeTimers ( {
172
182
global : globalThis ,
173
183
config : workerState . config . fakeTimers ,
You can’t perform that action at this time.
0 commit comments