Skip to content
masterclass Buddy

Vitest · Method

vi.waitFor

vi.waitFor retries a callback until it completes without throwing or rejecting, or until the wait times out. It returns the callback's successful result.

Last updated

Syntax

function waitFor<T>(callback: WaitForCallback<T>, options?: number | WaitForOptions): Promise<T>

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

Subscribe
  • expect.poll
  • vi.waitUntil
  • vi.useFakeTimers
  • vi.waitFor

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