Golden files are the source of truth for snapshot-based steps like Visual
diff. By default they’re stored on the dashboard; opt into local storage to
keep them alongside your tests.
Enable local storage
-
In your Visual diff step, omit the
screenshot key so Momentic stores
the snapshot locally:
- id: daaaca72-...
type: PRESET_ACTION
command:
id: c41afa9a-...
type: VISUAL_DIFF
threshold: 0.1
-
Snapshots are written to
<momentic-root>/golden/visual-diff/<command-id>.jpg by default:
momentic.config.yaml
golden/
visual-diff/
c41afa9a-....jpg
-
(Optional) Override the directory via
goldenFileDir in
momentic.config.yaml:
goldenFileDir: tests/snapshots
Update snapshots
npx momentic run --update-golden-files
--update-golden-files makes snapshot-based tests pass even when the current
state differs from the stored snapshot. Use it intentionally.
Colocate snapshots with tests
Point the screenshot.data field at a path relative to the Momentic root:
- id: b936be65-...
type: PRESET_ACTION
command:
id: 39282da9-...
type: VISUAL_DIFF
threshold: 0.4
screenshot:
data: momentic/tests/visual-diff/golden/upload-button.jpg
width: 1920
height: 1080
Resulting layout:
momentic.config.yaml
momentic/
tests/
visual-diff/
visual-diff.test.yaml
golden/
upload-button.jpg