Skip to content
masterclass Buddy

Vitest · Function

expect

Vitest's expect function creates runtime assertions. It supports Chai-style and Jest-style matchers, and a second argument can provide a custom failure message.

Last updated

Syntax

expect<T>(actual: T, message?: string): Assertion<void, T>

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

Subscribe
  • assert
  • expect.soft
  • expect.poll
  • not
  • toBe
  • toEqual
  • toBeCloseTo
  • expectTypeOf

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