Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snapshot Fails if different simulator chosen #10

Open
rfodge opened this issue Apr 8, 2024 · 2 comments
Open

Snapshot Fails if different simulator chosen #10

rfodge opened this issue Apr 8, 2024 · 2 comments

Comments

@rfodge
Copy link

rfodge commented Apr 8, 2024

When we run the tests for the first time and it records the snapshots, they will pass as long as we have that same simulator selected in xcode.
Here:
Screenshot 2024-04-08 at 4 24 02 PM

But why does this device that is selected matter if we are passing in the device configuration when we record and run the snapshot tests. So our tests have something like this
Testing_Previews.compactSnapshot.assertSnapshots(as: .image(layout: .device(config: .iPhone15ProMax(.portrait))))

If we were to run this test and have SE 3rd generation simulator selected for the device in xcode then this test will always run/pass if SE 3rd gen is picked. But if we run this test again another simulator like iPad mini then it will fail. Why does the device selected in Xcode menu matter if it allows us to pass in the device configuration we want used? 🤔

@teameh
Copy link

teameh commented Jul 23, 2024

Known issue. See readme https://github.com/pointfreeco/swift-snapshot-testing?tab=readme-ov-file#snapshot-anything or pointfreeco/swift-snapshot-testing#614

Warning Snapshots must be compared using the exact same simulator that originally took the reference to avoid discrepancies between images.

@jflan-dd
Copy link
Contributor

jflan-dd commented Oct 11, 2024

@rfodge The device configuration passed to assertSnapshots is just a size and safe area insets to capture the images using.

Using a different simulator in Xcode means that the tests are actually run on a different device (simulator) so lots of things can vary such as text spacing, default element sizing, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants