pointfreeco / swift-snapshot-testing

📸 Delightful Swift snapshot testing.
https://www.pointfree.co/episodes/ep41-a-tour-of-snapshot-testing
MIT License
3.77k stars 579 forks source link

Difference image doesn't show difference in opacity. #520

Open CraigSiemens opened 3 years ago

CraigSiemens commented 3 years ago

If the difference in two images is only the alpha channel but the rgb channels are the same, the difference image won't show that anything has changed.

Example

In this case it's a UILabel that has where the textColor is black (rgba(0, 0, 0, 1)) and the backgroundColor is clear (rgba(0, 0, 0, 0)).

Reference

Failure

Difference

If I take the reference and failure images and pass them to ImageMagick's compare command, it gives the following image showing the differences..

If I change view being snapshot to have a white background, then the created difference image shows the changes. While this does work, adding a background color to the view then means it isn't exactly the same as the view that'll be used in the app.

MartinMajewski commented 3 years ago

Sorry to highjack your question, but how do you get a difference-image anyway? We are trying to get at least the currently taken screenshot out of the device onto disk if it does not match the existing reference image (not when the reference image isn't present, that works). However, I haven't seen an option to get the newly taken image onto disk with a flagged name like "new", or "failed". Having a difference-image looks even better. But how?

CraigSiemens commented 3 years ago

It in the Reports navigator. In a test report, failing tests contain the reference, failure, and different files from the snapshot.

I believe they also exist in the xcresults archive created from running the tests.

BadPirate commented 7 months ago

Did you ever figure out the solution here? Experiencing the same thing in latest. @CraigSiemens