Vitest-native snapshot testing

Snapshot testing, done right

vitest-snap extends Vitest's expect with easy-to-use snapshot matchers — including filters, redactions, and a rich selector DSL.

import { describe, expect, test } from "vitest";describe("user API", () => {  test("returns user profile", async () => {    const user = await getUser(1);    await expect(user).toJsonSnapshot();  });});

Everything you need

Powerful features that make snapshot testing predictable and maintainable.

Zero Config

Works with your existing Vitest setup. Import and go — no plugins, no extra config.

Auto-Naming

Snapshot filenames are derived from the test name automatically. No boilerplate required.

Match-ers made in heaven

Snapshot with a variety of outputs: raw text, JSON, YAML, Markdown. See all matchers.

Parameterised Snapshots

Pass args to generate distinct snapshot files per test input. Each case gets its own file.

Filtering & Redactions

Scrub, replace, remove or sort values before snapshotting with a composable DSL.

Rich Selector Syntax

Target nested paths, array indices, slices, wildcards, and deep matches — with full TypeScript support.

Ready to start?

Add vitest-snap to your project in under a minute. Read the docs to learn more.

npm i vitest-snap -D
Read the docs →