Files
bun.sh/docs/test/snapshots.md
Colin McDonnell 9b6913e1a6 More/better docs for JSX, utils, binary data, streams, hashing, bun test, Bun.serve (#3005)
* WIP

* Updates

* Document deepEquals

* WIP

* Update typeS

* Update TLS docs for Bun.serve

* Update types for tls

* Draft binary data page. Add Streams page.

* Update test runner docs

* Add hashing, flesh out utils

* Grammar

* Update types

* Fix

* Add import.meta docs

* Tee
2023-05-29 11:49:51 -07:00

525 B

Snapshot tests are written using the .toMatchSnapshot() matcher:

import { test, expect } from "bun:test";

test("snap", () => {
  expect("foo").toMatchSnapshot();
});

The first time this test is run, the argument to expect will be serialized and written to a special snapshot file in a __snapshots__ directory alongside the test file. On future runs, the argument is compared against the snapshot on disk. Snapshots can be re-generated with the following command:

$ bun test --update-snapshots