Skip to content
masterclass Buddy

Vitest · Pipe

test.deps

vi.doMock replaces a module for the next dynamic import. It is not hoisted, so its factory can use variables from the file scope.

Last updated

Syntax

vi.doMock(path, factory?)
vi.doMock(module, factory?)

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

Subscribe
  • vi
  • vi.mock
  • MockOptions
  • MockFactory
  • Disposable

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