Skip to content

Test fails if simulator is changed #614

Closed
@tikekar

Description

@tikekar

Describe the bug
I had iphone 13 max simulator selected in my xcode project on which I ran the snapshot test to record. After that I changed the simulator and re ran the test. This time it fails with following error -
Newly-taken snapshot@(375.0, 812.0) does not match reference@(562.5, 1218.0).

But I have selected iphoneX in the image. Here is my sample testcase. So how to make this agnostic to simulator type? As I want to run this test on CI/CD, I would like the test to pass if a different simulator is chosen. Or is there a way to provide a constant simulator type to the test so that it always runs on same type.
let result = verifySnapshot(
matching: viewController,
as: .image(on: .iPhoneX), // Selected iphoneX
named: "MyPage",
record: false,
timeout: 20,
testName: "MyTest"
)

To Reproduce
Zip up a project that reproduces the behavior and attach it by dragging it here.

// And/or enter code that reproduces the behavior here.
let result = verifySnapshot(
            matching: viewController,
            as: .image(on: .iPhoneX), // Selected iphoneX
            named: "MyPage",
            record: false,
            timeout: 20,
            testName: "MyTest"
        )

Expected behavior
Test should pass even if the simulator it runs on is changed if the image type is provided.

Screenshots
Screen Shot 2022-07-07 at 5 06 50 PM
hots to help explain your problem.

Environment

  • swift-snapshot-testing version [e.g. 1.9.0]
  • Xcode [e.g. 13.2]
  • Swift [e.g. 5.5]
  • OS: [e.g. iOS 15]

Additional context
Add any more context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions