syrupy-project / syrupy

:pancakes: The sweeter pytest snapshot plugin
https://syrupy-project.github.io/syrupy/
Apache License 2.0
541 stars 37 forks source link

Add support for before/after diff using image files #886

Open jcampbell05 opened 2 months ago

jcampbell05 commented 2 months ago

Is your feature request related to a problem? Please describe.

By default we get a diff of the byte strings but that isn't the easiest way for comparing if an image looks the way you expect, I previously wrote a custom extension to allow syrupy to spit out an "after" PNG file if the current snapshot doesn't match like I am used to with other snapshot libraries.

Unfortunately the syrupy at the time was limited, required a lot of overriding of methods in the matcher and so it broke in later editions

Describe the solution you'd like

Ability for the latest snapshot that is failing to match to be written to a "file.after.png" file if it fails to match.

Describe alternatives you've considered

I previously implemented it in my own custom extension but it was fragile and broke when syrupy was upgraded, it ideally would be built in.

Additional context

noahnu commented 1 month ago

Could you share the code from the custom extension?