Skip to main content
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

ParameterTypeRequiredDescription
pathstringYesPath to the golden screenshot, relative to the test or module file.
thresholdnumberNoMaximum allowed visual difference (0-1). Lower is stricter. Default 0.1.
saveAsstringNoVariable to store this step’s return value on env.<name>.
retriesnumberNoTimes to retry the step on failure before failing the test.
skippedbooleanNoSkip 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