Jest should not write snapshot files to the filesystem if the -u/--updateSnapshot flag is not provided.
Actual behavior
Jest writes to the filesystem.
Additional context
Build systems like BuildXL that monitor the filesystem for reads and writes to cache builds will raise issues if unexpected writes happen. In CI, Jest snapshots should never be written.
Version
29.7.0
Steps to reproduce
.toMatchSnapshot()
testsjest -u
jest
under a debugger and observe thatsaveSnapshotFile
is called:https://github.com/jestjs/jest/blob/c54bccd657fb4cf060898717c09f633b4da3eec4/packages/jest-snapshot-utils/src/utils.ts#L138-L156
Expected behavior
Jest should not write snapshot files to the filesystem if the
-u
/--updateSnapshot
flag is not provided.Actual behavior
Jest writes to the filesystem.
Additional context
Build systems like BuildXL that monitor the filesystem for reads and writes to cache builds will raise issues if unexpected writes happen. In CI, Jest snapshots should never be written.
Environment