> ## Documentation Index
> Fetch the complete documentation index at: https://momentic.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# visualDiff

> Compare a full-screen screenshot against a golden image.

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.

<Note>
  `visualDiff` is only supported when running mobile tests locally with the
  Momentic CLI. Golden files live on the machine that runs the test.
</Note>

## 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.

```yaml theme={null}
- visualDiff: ./golden/visual-diff/home.png
```

## Examples

```yaml theme={null}
- visualDiff:
    path: ./golden/visual-diff/home.png
    threshold: 0.05
```

## Related

* [Golden files](/guides/visual-testing/golden-files)
* [Test format](/core-concepts/test-format)
