BarredEwe / Prefire

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

Added snapshot settings for previews #17

Closed BarredEwe closed 1 year ago

BarredEwe commented 1 year ago

It was difficult, but finally I managed to add delay and precision for snapshots. I have added a function:

struct TestView_Previews: PrefireProvider {
    static var previews: some View {
        TestView()
            .snapshot(delay: 0.1, precision: 1)
    }
}

This function affects snapshot generation, transit delay, and precision.:

// Generated snapshot test
assertSnapshot(
    matching: view,
    as: .wait(for: delay, on: .image(precision: precision ?? 1, layout: isScreen ? .device(config: device) : .sizeThatFits)),
    named: preview.displayName,
    testName: testName
)
BarredEwe commented 1 year ago

I made this improvement based on the idea from this issue: https://github.com/BarredEwe/Prefire/issues/11