Skip to content
masterclass Buddy

Vitest · Matcher

toMatchFileSnapshot

toMatchSnapshot checks a value against a saved Vitest snapshot. It creates the snapshot on the first run and fails when later output differs.

Last updated

Syntax

expect(received).toMatchSnapshot(hint?: string)

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

Subscribe
  • toMatchInlineSnapshot
  • toThrowErrorMatchingSnapshot
  • toThrowErrorMatchingInlineSnapshot
  • toMatchFileSnapshot
  • toMatchAriaSnapshot
  • toMatchScreenshot

Source: Snapshot Testing | Guide | Vitest. Checked 2026-11-03.