vitest-dev / vitest

Next generation testing framework powered by Vite.
https://vitest.dev
MIT License
12.63k stars 1.13k forks source link

Support visual regression in the browser #6265

Open sheremet-va opened 1 month ago

sheremet-va commented 1 month ago

Clear and concise description of the problem

There is no built-in way to compare images in the browser mode.

Suggested solution

Implement a snapshot-style assertion to compare previously stored images. I am open to API ideas.

This issue is opened to start a discussion around the topic.

Alternative

No response

Additional context

Consider using https://github.com/mapbox/pixelmatch as it is small and fast

Validations

AriPerkkio commented 1 month ago

I'm not sure if this should be part of the core. Or at least it should be marked as very-very experimental all the time.

Comparing images is very hard. There are companies building products that especially focus on this, and using those can be expensive. Open source tools like jest-image-snapshot and cypress-image-snapshot (that use pixelmatch) are very flaky, especially when comparing images that are generated on different operating systems. For example pixel-by-pixel comparison fails in as simple cases as rendering fonts.

If we can find a way to implement this confidently then I'm all in. 👍

@JessicaSachs any thoughts? Do you have experience on this area?