Skip to content
masterclass Buddy

Vitest · Method

vi.importMock

vi.importMock asynchronously imports a module with all its properties deeply mocked. This includes nested properties.

Last updated

Syntax

function importMock<T>(path: string): Promise<MaybeMockedDeep<T>>

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • vi.mock
  • vi.importActual
  • vi.unmock
  • vi.doUnmock

Source: Vi | Vitest. Checked 2026-11-03.