mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
* 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
16 lines
525 B
Markdown
16 lines
525 B
Markdown
Snapshot tests are written using the `.toMatchSnapshot()` matcher:
|
|
|
|
```ts
|
|
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:
|
|
|
|
```bash
|
|
$ bun test --update-snapshots
|
|
```
|