Quick Start
Getting Started with vitest-snap.
Introduction
vitest-snap like its name suggest is a Snapshot testing library based on the Vitest testing framework.
Features
- Auto-naming — snapshot filenames are derived from the test name automatically; no boilerplate required
- Parameterised snapshots — pass
argsto generate distinct snapshot files per test input - Filtering & redactions — scrub, replace, remove or sort values before snapshotting with a composable DSL
- Date redaction by default —
Dateinstances are replaced with[Date_1],[Date_2], … out of the box - Undefined filtered by default —
undefinedprops are removed from objects to unclutter test snahpsots - Rich selector syntax — target nested paths, array indices, slices, wildcards, and deep matches; with full TypeScript support
- Zero config — works with your existing Vitest setup
Installation
npm i vitest-snap -DThen register the matchers in your Vitest setup file:
import "vitest-snap";import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
setupFiles: ["./vitest.setup.ts"],
},
});Agent Skills
AI coding agents (Claude Code, Cursor, Copilot, etc.) can install vitest-snap skills to get accurate, pattern-aware guidance for this library:
npx @tanstack/intent@latest install vitest-snapLast updated on