swift-snapshot-testing
swift-snapshot-testing copied to clipboard
Not possible to have device agnostic screenshots with iPad AND iPhone
I would like to test my view on both, an iPad and iPhone. Let's assume a very simple view:
struct SimpleView: View {
var body: some View {
if UIDevice.current.userInterfaceIdiom == .pad {
Text("iPad")
} else {
Text("iPhone")
}
}
}
which is tested like the following
assertSnapshot(matching: SimpleView(), as: .image(layout: .device(config: .iPhoneX)))
assertSnapshot(matching: SimpleView(), as: .image(layout: .device(config: .iPadMini(.landscape))))
Then it depends on the simulator that setup... when I set it to iPad, both snapshots are taken with "iPad" - and the same for iPhone.
It would be great if it's possible to have it in a way that the two snapshots read "iPhone" and "iPad".
@haemi I believe better practice is to operate on SizeClasses rather than device type. https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/adaptivity-and-layout/