Skip to content
masterclass Buddy

Vitest · Matcher

toMatchSnapshot

toMatchSnapshot checks a value against a stored Vitest snapshot. It creates the snapshot on the first run and fails later when the serialized output changes.

Last updated

Syntax

toMatchSnapshot<T>(shape?: Partial<T> | string, hint?: string): void

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

Subscribe
  • expect
  • toMatchInlineSnapshot
  • toMatchFileSnapshot
  • toThrowErrorMatchingSnapshot
  • toThrowErrorMatchingInlineSnapshot
  • snapshotFormat
  • snapshotSerializers

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