pointfreeco / swift-snapshot-testing

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

Add watchOS support #705

Open jverkoey opened 1 year ago

jverkoey commented 1 year ago

E.g. the .image Diffing strategy is only available when #if os(iOS) || os(tvOS). This means the strategy is unavailable in os(watchOS) targets.

jverkoey commented 1 year ago

It looks like one are that might prove tricky is the absence of CoreImage.CIKernel on the watch. perceptuallyCompare relies on this framework.

johankool commented 1 year ago

No perceptual precision, but otherwise I have something working here.

cprince-foreflight commented 11 months ago

Just to confirm, there is no watchOS support in this snapshot testing for SwiftUI VIew's presently, right? E.g.,

assertSnapshot(of: view, as: .image(layout: .sizeThatFits))

works on iOS but will not compile on watchOS. i..e, I get the following

Cannot infer contextual base in reference to member 'sizeThatFits'
Generic parameter 'Format' could not be inferred
Type 'Snapshotting<ExampleView, _>' has no member 'image'
johankool commented 11 months ago

@cprince-foreflight That's right, the library itself doesn't support watchOS. This is because the feature that is used to compare images that only slightly differ uses API that isn't available on watchOS. In my comment above I link to a version that is based on another way to create the images, and lacks the ability to compare slightly different images, but does work on watchOS. I've not yet taken that PR out of draft as I haven't used it "in anger" since.