Open darrarski opened 3 years ago
Hi @darrarski, did you get any further with this? I'm struggling with the same problem, but for me it's my laptop versus GitHub Actions.
Unfortunately, I didn't have time to work on this issue and research for a solution.
Scaling the images down seems a dead end. Anti-aliasing and font-smoothing result in inconsistent results.
As a workaround I unscale the MacBook Retina display with https://github.com/th507/screen-resolution-switcher before I take the snapshots, and revert it afterwards. For my MacBook 16", it's like
scres -s 3072
xcodebuild ... test
scres -r 1536
This works for my use case of GitHub Actions.
Wonder if anyone has any luck making output sharper from macOS snapshots?
When snapshot testing views on macOS recorded image size depends on the main display of the machine on which tests are run.
Example:
When snapshot testing views on iOS, I can provide a display scale trait collection to force the output image scale (as described in #427). Unfortunately, I haven't found a way to snapshot test macOS views, so the test results are not dependent on the display I am using (MacBook-embedded or external monitor).
I tried to work-around this issue with the code below:
And while it fixes the mismatch of the output image size (with the code above it will always equal to point-size of the view), it does not work as expected. It looks like scaling the image introduces minor distortion which causes test failures (for example, text on the snapshot image is slightly shifted 1 px).
Is there a way of forcing the scale of a snapshot image on macOS?