BarredEwe / Prefire

🔥 A library based on SwiftUI Preview, for easy generation: Playbook view, Snapshot and Accessibility tests
Apache License 2.0
251 stars 16 forks source link

Add support for snapshotting multiple devices in one go #38

Closed stefanceriu closed 4 months ago

stefanceriu commented 4 months ago

Let me just start by saying that we're absolutely delighted by Prefire so thank you very much for making it happen! 👏

We've been using it for quite some time now in Element X with great success and we would like to take it one step further.

We're currently also using UI tests to snapshot multiple devices and languages but those are more cumbersome to setup and run so we would like to switch them to Prefire too.

We can do so by building custom ViewImageConfigs and simulate other devices no matter what simulator you're running on, which is what this PR aims to add. Different languages can be handled by adding extra xctestplan configurations and running the generated tests multiple times + a small tweak to the tests template to include the language in the screenshot name e.g. https://github.com/element-hq/element-x-ios/blob/develop/UITests/Sources/Application.swift#L74

It seems to be working well for the Prefire Example project and I would try it out in Element X but I'm blocked on https://github.com/BarredEwe/Prefire/issues/37. I do have another implementation of this based on Prefire 1 which worked just fine so I have no reason to believe it won't do the job.

Hope this all makes sense and that I'm not missing anything.

P.S. I also tried removing checkEnvironments entirely and let you run on any simulator but there's weird text rendering kerning issues between devices that I wasn't able to figure out. For example the iPhone 15 family works no matter which one you chose but iPads an iPhone SE renders text slightly differently, enough to break the tests.

woutergoossens commented 4 months ago

Really like the PR, would be a great addition ;)

stefanceriu commented 4 months ago

Alrighty, with 37 out of the way I had no problem setting this up in Element X, just a few configuration changes. We now have 1000 new shiny snapshots https://github.com/element-hq/element-x-ios/commit/6ea320e4def0514f980604b4c7d93b40a7a0d723

It's especially nice to see one in which the size classes actually matter, like this split view test we have: iPad vs iPhone

Otherwise, I've updated the version and binary. Anything else I need to do before we can get this merged?

BarredEwe commented 4 months ago

Let's add information about the new feature in Readme.md?)

stefanceriu commented 4 months ago

Oh, of course. I've added something, have a look please

stefanceriu commented 4 months ago

Bump 👋

BarredEwe commented 4 months ago

@stefanceriu Congratulations on the completed Merge Request 🥳

Thank you so much for such a cool feature! ❤️

stefanceriu commented 4 months ago

Yey, it was my absolute pleasure! Thank you too! 🥳