rembrembdocs

See what changed

git diff snapshots/

Update if changes are intentional

bun test --update-snapshots

Commit the updated snapshots

git add snapshots/ git commit -m "Update snapshots after UI changes"


### Cleaning Up Unused Snapshots

Bun will warn about unused snapshots:

warning

Warning: 1 unused snapshot found: my-test.test.ts.snap: "old test that no longer exists 1"


Remove unused snapshots by deleting them from the snapshot files or by running tests with cleanup flags if available.

### Organizing Large Snapshot Files

For large projects, consider organizing tests to keep snapshot files manageable:

directory structure

tests/ ├── components/ │ ├── Button.test.tsx │ └── snapshots/ │ └── Button.test.tsx.snap ├── utils/ │ ├── formatters.test.ts │ └── snapshots/ │ └── formatters.test.ts.snap


## Troubleshooting

### Snapshot Failures

When snapshots fail, you’ll see a diff:

diff


Common causes:

*   Intentional changes (update with `--update-snapshots`)
*   Unintentional changes (fix the code)
*   Dynamic data (use property matchers)
*   Environment differences (normalize the data)

### Platform Differences

Be aware of platform-specific differences:

![https://mintcdn.com/bun-1dd33a4e/JUhaF6Mf68z\_zHyy/icons/typescript.svg?fit=max&auto=format&n=JUhaF6Mf68z\_zHyy&q=85&s=7ac549adaea8d5487d8fbd58cc3ea35b](https://mintcdn.com/bun-1dd33a4e/JUhaF6Mf68z_zHyy/icons/typescript.svg?fit=max&auto=format&n=JUhaF6Mf68z_zHyy&q=85&s=7ac549adaea8d5487d8fbd58cc3ea35b)test.ts

// Paths might differ between Windows/Unix test("file operations", () => { const result = processFile("./test.txt");

expect({ ...result, path: result.path.replace(/\/g, "/"), // Normalize paths }).toMatchSnapshot(); });