You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bun test --update-snapshots rewrites the .snap file in execution order, reordering unchanged entries #42969
bun test order.test.ts writes __snapshots__/order.test.ts.snap with suite zeta 1 before suite alpha 1 (execution order).
Hand-sort the file (alpha first), run bun test order.test.ts: passes, order kept. Add a third test: the new entry is appended. Good so far.
bun test --update-snapshots order.test.ts: the file is rewritten as zeta, mid, alpha, i.e. every unchanged entry moves.
What is the expected behavior?
Jest sorts snapshot keys (natural compare) on every write, so a regenerated file only shows the entries whose values changed. Either sorted keys, or keeping the existing file order and appending new keys (what the plain run already does), would keep --update-snapshots diffs reviewable.
What do you see instead?
--update-snapshots emits entries in the order the tests ran, so a one-value update to a file whose tests are not declared alphabetically reorders the whole file. In a repo with 10 snapshot files and 87 entries the migration diff was about 2900 lines of reorder for one changed value.
Additional information
Related: node:test's t.assert.snapshot is not implemented in the node:test shim, so suites moving from Node's runner also lose the >-joined keys and the <test>.snapshot file next to the test.
Reproduced on 1.4.3: bun test --update-snapshots truncates the .snap file and writes every entry in execution order.
Fix in progress: #43043. It keeps the existing file order, replaces changed values in place, and appends new keys. It also keeps the entries of tests that did not run (-t, .only, .skip). It replaces #42980.
Activity
robobun commentedon Sep 16, 2026
Reproduced on 1.4.3:
bun test --update-snapshotstruncates the.snapfile and writes every entry in execution order.Fix in progress: #43043. It keeps the existing file order, replaces changed values in place, and appends new keys. It also keeps the entries of tests that did not run (
-t,.only,.skip). It replaces #42980.