Vitest · Module
returns
Vitest’s vi helper provides APIs for mocking modules, functions, and objects. Use vi.mock for hoisted module mocks and vi.doMock when the mock must be set up before a later dynamic import.
Last updated
Syntax
function mock(path: string, factory?: MockOptions | MockFactory<unknown>): void
function mock<T>(module: Promise<T>, factory?: MockOptions | MockFactory<T>): voidIn-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
vi.doMockvi.doUnmockvi.mockedvi.resetModulesvi.fnvi.mockObjectvi.spyOnvi.hoisted