aboutsummaryrefslogtreecommitdiff
path: root/docs/test/snapshots.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/test/snapshots.md')
-rw-r--r--docs/test/snapshots.md15
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/test/snapshots.md b/docs/test/snapshots.md
new file mode 100644
index 000000000..46df217ce
--- /dev/null
+++ b/docs/test/snapshots.md
@@ -0,0 +1,15 @@
+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
+```