Skip to main content
On first run, captures the golden image and stores it next to the test. On subsequent runs, fails the step if the rendered region differs by more than threshold. Re-record a golden by deleting it and re-running. The bare form - visualDiff diffs the full viewport.

Parameters

ParameterTypeRequiredDescription
onstringNoDescription of the element to diff against.
cssstringNoCSS selector for the target. Use instead of the description key.
coordsstring | { x, y }NoAbsolute viewport coordinates. Either an x, y string (e.g. 120, 40) or a { x, y } object.
xnumber | stringNoX coordinate. Must be provided together with y.
ynumber | stringNoY coordinate. Must be provided together with x.
forcebooleanNoForce the action even when the element is not actionable.
iframestringNoURL or URL pattern of the iframe that contains the target element.
thresholdnumberNoMaximum allowed visual difference. 0 = identical.
saveAsstringNoName of the variable to write this step’s return value to.
retriesnumberNoNumber of times to retry the step on failure before failing the test.
skippedbooleanNoSkip this step at execution time.

Shorthand

Bare command. Diffs the full viewport.
- visualDiff

Examples

- visualDiff:
    threshold: 0.1
- visualDiff:
    on: the 'Start HTTP upload' button
    threshold: 0.4
    screenshot:
      data: momentic/tests/visual-diff/golden/upload-button.jpg
      width: 125
      height: 20
- visualDiff:
    threshold: 0.1
    screenshot:
      data: https://screenwriter-test-code.s3.us-west-1.amazonaws.com/screenshots/abbd74b9-b4e1-4c70-abd1-56093db36ffe.jpg
      width: 1920
      height: 1080