# Update snapshots in `bun test` (/docs/guides/test/update-snapshots)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 206 · updated: 2026-07-28 -->
Related: [Run your tests with the Bun test runner](/docs/guides/test/run-tests.md), [Run tests in watch mode with Bun](/docs/guides/test/watch-mode.md), [Migrate from Jest to Bun's test runner](/docs/guides/test/migrate-from-jest.md), [Mock functions in `bun test`](/docs/guides/test/mock-functions.md), [Spy on methods in `bun test`](/docs/guides/test/spy-on.md), [Set the system time in Bun's test runner](/docs/guides/test/mock-clock.md)

Bun's test runner supports Jest-style snapshot testing with `.toMatchSnapshot()`.

```ts snap.test.ts icon="/icons/typescript.svg"
import { test, expect } from "bun:test";

test("snapshot", () => {
  expect({ foo: "bar" }).toMatchSnapshot();
});
```

***

The first time this test runs, Bun writes a snapshot file to a `__snapshots__` directory alongside the test file.

```txt File Tree icon="folder-tree"
test
├── __snapshots__
│   └── snap.test.ts.snap
└── snap.test.ts
```

***

To regenerate snapshots, use the `--update-snapshots` flag.

```sh terminal icon="terminal"
bun test --update-snapshots
```

```txt
test/snap.test.ts:
✓ snapshot [0.86ms]

 1 pass
 0 fail
 snapshots: +1 added # the snapshot was regenerated
 1 expect() calls
Ran 1 tests across 1 files. [102.00ms]
```

***

See [Snapshots](/test/snapshots).
