Captures a full-screen screenshot and compares it pixel-by-pixel against a
golden image stored on disk. On first run the golden file is created and the
step passes. On subsequent runs the step fails if the screenshot differs by more
than threshold. To refresh a golden after an intentional UI change, re-run
with --update-golden-files.
The simplified form takes the golden file path as a single string. Element
targeting is not supported on mobile; the diff always covers the full screen.
visualDiff is only supported when running mobile tests locally with the
Momentic CLI. Golden files live on the machine that runs the test.
Parameters
| Parameter | Type | Required | Description |
|---|
path | string | Yes | Path to the golden screenshot, relative to the test or module file. |
threshold | number | No | Maximum allowed visual difference (0-1). Lower is stricter. Default 0.1. |
saveAs | string | No | Variable to store this step’s return value on env.<name>. |
retries | number | No | Times to retry the step on failure before failing the test. |
skipped | boolean | No | Skip this step at execution time. |
Shorthand
Golden file path as a single string.
- visualDiff: ./golden/visual-diff/home.png
Examples
- visualDiff:
path: ./golden/visual-diff/home.png
threshold: 0.05