Use this file to discover all available pages before exploring further.
Snapshot testing saves the serialized output of a value and compares it on future runs. This is useful for complex objects, component output, or any value that should remain stable over time.
import { test, expect } from "bun:test";test("formats user object", () => { const user = { id: 1, name: "Alice", role: "admin" }; expect(user).toMatchSnapshot();});
On the first run, the value is serialized and written to a snapshot file. On subsequent runs, the value is compared against the stored snapshot — the test fails if they differ.
For small values, use .toMatchInlineSnapshot() to store the snapshot directly in the test file. On the first run, Bun writes the value into your test file automatically.
Snapshot only the part of the output that matters to the test. Large snapshots are hard to review when they change.
// Good: snapshot a specific fieldexpect(response.body).toMatchInlineSnapshot(`"success"`);// Avoid: snapshotting an entire page renderexpect(renderFullPage()).toMatchSnapshot();
Handle dynamic data with property matchers
// Good: normalize volatile fieldsexpect(apiResponse).toMatchSnapshot({ timestamp: expect.any(Number), requestId: expect.any(String),});// Avoid: snapshots that break on every runexpect(apiResponse).toMatchSnapshot(); // contains Date.now()
Review snapshot changes carefully
Snapshot diffs in pull requests deserve the same scrutiny as code changes. An unexpected snapshot change is often a sign of a bug.
Group snapshots with describe
Organizing snapshots inside describe blocks makes the snapshot file easier to navigate: