-
Notifications
You must be signed in to change notification settings - Fork 37
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
How to implement image diffing for visual regression testing #566
Comments
Same as with the other discussion, sorry about the delayed response. The That being said, it'd be fairly trivial to update this logic to let a custom extension override the equality check. That'd also enable other sorts of "tolerance" assertions. If there is still interest in this, we can move this discussion to a feature request. Originally posted by @noahnu in #536 (comment) |
What is the status of being able to create a custom SnapshotReporter that uses a tool like pixelmatch? |
It should be doable now. Something along the lines of: class PixelMatchSnapshotExtension(PNGImageSnapshotExtension):
def matches(self, *, serialized_data, snapshot_data) -> bool:
pass # run pixelmatch here
def diff_snapshots(self, serialized_data, snapshot_data) -> "SerializableData":
pass # re-run pixelmatch and return a diff image (can cache on the class instance)
@pytest.fixture
def visual_snapshot(snapshot):
return snapshot.use_extension(PixelMatchSnapshotExtension)
def test_case(visual_snapshot):
assert generate_image(....) == visual_snapshot If you end up implementing a visual regression testing extension based on syrupy, consider open sourcing it and I can link to it on our README under a community section. |
This should be doable using a custom extension, see above comment. Closing the issue. |
Discussed in #536
Originally posted by rassie August 4, 2021
If I understand the documentation correctly, it's possible to implement a snapshot extension which would compare images visually (e.g. with pixelmatch) instead of byte-wise. Is it a matter of writing a custom
SnapshotReporter
and mix it into an extension or would I need to do more?The text was updated successfully, but these errors were encountered: