-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(browser): support custom screenshot comparison algorithms #8687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
docs/guide/browser/config.md
Outdated
|
|
||
| - **Type:** `Record<string, Comparator>` | ||
|
|
||
| Register custom screenshot comparison algorithms, like SSIM or perceptual diff implementations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add links here? That explain what SSIM and perceptual diff mean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had some issues when writing this... Went through a few iterations as I didn't know how much "beginner-friendly" to be.
I landed on "this is an advanced feature, people that are looking for it already know what they want to do with a custom comparator" so I didn't went into too much detail explaining different diffing algorithms, just provided some search terms.
If you think we should add some links, I can try finding some sources (probably Wikipedia for a general overview).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wikipedia links would be great
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the link (for SSIM) and reworded the final bit to "perceptual similarity metrics", which is more accurate. I don't have a link to this tho, as I believe it's more of an academic topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Description
Adds support for custom screenshot comparison algorithms in
toMatchScreenshotso users can now register them in their config.The video shows the TypeScript integration: when you declare a comparator in
ScreenshotComparatorRegistry, it automatically becomes available in the config with full type checking: required registration, correct option types, and autocomplete forcomparatorName.fancy-comparator-demo.mp4
Custom comparators are registered in the config under
browser.expect.toMatchScreenshot.comparators:Then can be used in tests:
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.