Pixel-diff an implementation against a contract screenshot
diff_pixelsCompare rendered implementation against a reference screenshot pixel by pixel to detect subtle visual differences. Use after structural checks; returns diff percentage and image path.
Instructions
Renders the implementation URL and compares it pixel by pixel against the reference screenshot stored in the contract. Use this for a stricter visual check than check_implementation, after the structural check passes or when a subtle rendering difference is suspected. Requires the contract to have been extracted with screenshotDir set. Returns the percentage of differing pixels, the threshold it was compared against, ok, and the filesystem path of the generated diff image.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The implementation URL to capture and compare pixel by pixel. | |
| wait | No | Extra settle time in milliseconds after navigation. Defaults to 2000. | |
| masks | No | CSS selectors to blank out before comparing, for example ads or timestamps. | |
| outDir | No | Directory to write the diff image to. Defaults to the OS temp directory. | |
| timeout | No | Navigation timeout in milliseconds. Defaults to 30000. | |
| headless | No | Run the browser headless. Defaults to true. | |
| selector | No | CSS selector to scope the comparison to. Defaults to the contract root. | |
| viewport | No | Viewport name to compare. Defaults to the first viewport in the contract. | |
| threshold | No | Allowed percent of differing pixels before the comparison fails. Defaults to 0.5. | |
| contractPath | Yes | Path to a contract JSON file previously written by extract_contract. |