.toMatchSnapshot().
The first time this test runs, Bun evaluates the value passed into
expect() and writes it to a __snapshots__ directory alongside the test file. (Note the snapshots: +1 added line in the output.)
terminal
The
__snapshots__ directory contains a .snap file for each test file in the directory.
File Tree
The
snap.test.ts.snap file is a JavaScript file that exports a serialized version of the value passed into expect(). The {foo: "bar"} object has been serialized to JSON.
snap.test.ts.snap
On later runs, Bun reads the snapshot file and compares it to the value passed into
expect(). If they differ, the test fails.
terminal
To update snapshots, use the
--update-snapshots flag.
terminal
See Snapshots.