feat(browser): support custom screenshot comparison algorithms#8687
feat(browser): support custom screenshot comparison algorithms#8687sheremet-va merged 4 commits intovitest-dev:mainfrom
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.
Should we add links here? That explain what SSIM and perceptual diff mean
There was a problem hiding this comment.
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.
Wikipedia links would be great
There was a problem hiding this comment.
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.
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:.