Vitest · Method
vi.stubGlobal
vi.stubGlobal replaces a global variable during a test. Use vi.unstubAllGlobals or the unstubGlobals setting to restore it.
Last updated
Syntax
function stubGlobal(name: string | number | symbol, value: unknown): VitestIn-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
vi.unstubAllGlobalsunstubGlobalsglobalThisvi.fn