swift-snapshot-testing icon indicating copy to clipboard operation
swift-snapshot-testing copied to clipboard

Introduce optional reference device checks

Open erikpoort opened this issue 4 years ago • 1 comments

Hi, I am part of a big team of many developers working a single app, where I introduced your library. Many times I will get one of these developers asking me why all the snapshots are failing, often the solution is to switch to the simulator which was used to create the reference images. They didn't know this was needed, and then they didn't know what simulator to use.

So this is my proposed solution. You can setup two vars, called referenceDevice and referenceMajorOSVersion. When these are set, for every snapshot (record on or off) the library will now check the simulator used, against these values. If they do not match, the test will fail even before actually making the snapshot, explaining that you are using the wrong simulator.

I wanted to see what you think of it, before continuing to work on this!

erikpoort avatar Sep 17 '20 15:09 erikpoort

@stephencelis @mbrandonw Hey guys, I was wondering what you though about this idea / approach / solution?

It's an optional and lightweight way to prevent developers from finding out about the simulator issue, before creating / committing / pushing the snapshots:

⚠️ Warning: Snapshots must be compared using a simulator with the same OS, device gamut, and scale as the simulator that originally took the reference to avoid discrepancies between images.

Happy to some more work based on your comments / ideas!

erikpoort avatar Mar 03 '21 10:03 erikpoort