Code Monkey home page Code Monkey logo

Comments (4)

mbrandonw avatar mbrandonw commented on June 14, 2024

This is most likely due to running tests on CI in a different simulator than what you run locally. You should try to keep them the same because there can be differences, like screen sizes and small rendering artifacts.

In this case of this .333333, that is most likely coming up because CI is running on a 3x device. You probably captured the snapshot locally on a 2x device, and so you will see:

320 = (3/2) * 213.33333333333334
44  = (3/2) * 29.333333333333332

The 3/2 factor is because you snapshot at 2x and are verifying on 3x.

Hope that helps!

from swift-snapshot-testing.

sarunw avatar sarunw commented on June 14, 2024

Thanks!!! Yes, that is the case, but this error message is very misleading.
Shouldn't it be something like

Expected snapshot@(960.0, 132.0) to match reference@(640, 88.0)

Instead of

Expected snapshot@(320.0, 44.0) to match reference@(213.33333333333334, 29.333333333333332)

Don't understand what lib trying to do with that 3/2 factor if it wants to make the test compatible with all device regardless of a device running the test it should apply that factor against the result of testing device 960x132 (3x device)

so it would be 960 x 2/3 = 640 which equal recorded reference size.

And I don't see any 1x 2x 3x information in the reference image name, how can lib assume 2x in form factor?

from swift-snapshot-testing.

mbrandonw avatar mbrandonw commented on June 14, 2024

Yeah, that failure message isn't great and we can try to make it better.

Don't understand what lib trying to do with that 3/2 factor if it wants to make the test compatible with all device regardless of a device running the test it should apply that factor against the result of testing device 960x132 (3x device)

When we say that you can take device agnostic screenshots, we mean that in one test suite you can take screenshots for various screen sizes, like small iPhone's and iPad's, and we'll override the trait environment to make it seem like it's really that device. This means you don't have to boot up multiple simulators just to capture those different sizes. However, if you run that test suite on different simulators you will get subtly different results. Bugs have been filed with Apple to try to bridge that gap, but they claim it works as expected.

from swift-snapshot-testing.

stephencelis avatar stephencelis commented on June 14, 2024

This issue has gotten a bit stale so I'm going to close it out, @sarunw. If it's still an issue, or if you have suggestions to improve the error messaging, please let us know!

from swift-snapshot-testing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.