Guide for working with and updating insta snapshot tests in Oxc without terminal interaction.
This skill guides you through working with insta snapshot tests in the Oxc codebase without requiring terminal interaction.
Insta is a snapshot testing library for Rust. Oxc uses it extensively for:
crates/oxc_linter/src/snapshots/)crates/oxc_semantic/tests/integration/snapshots/)Snapshots track expected test outputs (often failures or errors). When code changes, new snapshots are generated as .snap.new files for review.
cargo test -p <crate_name>
This generates .snap.new files if test outputs have changed.
IMPORTANT: Avoid using cargo insta review (the interactive terminal UI). Instead, follow these steps:
cargo insta pending-snapshots
# Or for workspace-wide:
cargo insta pending-snapshots --workspace
This shows all .snap.new files waiting for review.
New snapshots are stored as .snap.new files next to their corresponding .snap files. You can use cargo insta pending-snapshots to view the changes to the snapshot files.
Accept all pending snapshots:
cargo insta accept
# Or workspace-wide:
cargo insta accept --workspace
Accept specific snapshot(s):
cargo insta accept --snapshot <snapshot_name>
Reject all pending snapshots:
cargo insta reject
# Or workspace-wide:
cargo insta reject --workspace
This deletes all .snap.new files.
After accepting, the .snap.new files become .snap files. Check with git:
git diff <path/to/snapshots/>
cargo test -p oxc_linter (or relevant crate)cargo insta pending-snapshotscargo insta accept.snap filescargo test -p oxc_linter specific_test_namecargo insta pending-snapshots - look for specific_test_name.snap.newcargo insta accept -p oxc_linter.snap - Current expected output.snap.new - New output from recent test run (pending review), do not commit if these files are presentNote that .snap.md files are from Vitest, and not Insta. They are used in conformance tests, and are not handled by the instructions in this skill.
git diff after accepting to see what actually changed.snap files.# 1. Make a code change to a linter rule
# 2. Run tests
cargo test -p oxc_linter
# 3. See what changed
cargo insta pending-snapshots
# 4. Review specific snapshot (using Read tool)
# Read: crates/oxc_linter/src/snapshots/some_test.snap.new
# 5. Accept if correct
cargo insta accept -p oxc_linter
# 6. Verify with git
git diff crates/oxc_linter/src/snapshots/
# 7. Run tests again to ensure everything passes
cargo test -p oxc_linter
When to use this skill: When tests fail due to snapshot mismatches or after changing code that affects test outputs.