Skip to content
masterclass Buddy

Vitest · Method

vi.hoisted

vi.hoisted runs a factory before static imports are evaluated. It returns the factory result, which can provide values to a hoisted vi.mock factory.

Last updated

Syntax

function hoisted<T>(factory: () => T): T

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

Subscribe
  • vi.mock
  • vi.doMock
  • vi.resetModules
  • vi.importActual

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