diff --git a/Tests/StoreKitUnitTests/Support/DebugViewSwiftUITests.swift b/Tests/StoreKitUnitTests/Support/DebugViewSwiftUITests.swift index 507bef9a82..1cffdd0a91 100644 --- a/Tests/StoreKitUnitTests/Support/DebugViewSwiftUITests.swift +++ b/Tests/StoreKitUnitTests/Support/DebugViewSwiftUITests.swift @@ -31,8 +31,7 @@ class DebugViewSwiftUITests: TestCase { } func testLoadingState() { - expect(self.view(with: .init(), width: 300, height: 400)) - .to(haveValidSnapshot(as: .image)) + self.snapshot(.init(), width: 300, height: 400) } func testDebugView() throws { @@ -55,8 +54,7 @@ class DebugViewSwiftUITests: TestCase { response: .mockResponse )) - expect(self.view(with: model, width: 450, height: 900)) - .to(haveValidSnapshot(as: .image)) + self.snapshot(model, width: 450, height: 900) } } @@ -64,15 +62,16 @@ class DebugViewSwiftUITests: TestCase { @available(iOS 16.0, *) private extension DebugViewSwiftUITests { - func view( - with model: DebugViewModel, + func snapshot( + _ model: DebugViewModel, width: CGFloat, height: CGFloat - ) -> some View { + ) { NavigationView { DebugSummaryView(model: model) } .frame(width: width, height: height) + .snapshot(size: CGSize(width: width, height: height)) } static var mockCustomerInfo: CustomerInfo { diff --git a/Tests/StoreKitUnitTests/Support/__Snapshots__/DebugViewSwiftUITests/iOS16-testDebugView.1.png b/Tests/StoreKitUnitTests/Support/__Snapshots__/DebugViewSwiftUITests/iOS16-testDebugView.1.png index 8f649c472d..5bbe37eaf2 100644 Binary files a/Tests/StoreKitUnitTests/Support/__Snapshots__/DebugViewSwiftUITests/iOS16-testDebugView.1.png and b/Tests/StoreKitUnitTests/Support/__Snapshots__/DebugViewSwiftUITests/iOS16-testDebugView.1.png differ diff --git a/Tests/StoreKitUnitTests/Support/__Snapshots__/DebugViewSwiftUITests/iOS16-testLoadingState.1.png b/Tests/StoreKitUnitTests/Support/__Snapshots__/DebugViewSwiftUITests/iOS16-testLoadingState.1.png index 4705bd8982..b55c5b3c40 100644 Binary files a/Tests/StoreKitUnitTests/Support/__Snapshots__/DebugViewSwiftUITests/iOS16-testLoadingState.1.png and b/Tests/StoreKitUnitTests/Support/__Snapshots__/DebugViewSwiftUITests/iOS16-testLoadingState.1.png differ diff --git a/Tests/StoreKitUnitTests/Support/__Snapshots__/DebugViewSwiftUITests/iOS17-testDebugView.1.png b/Tests/StoreKitUnitTests/Support/__Snapshots__/DebugViewSwiftUITests/iOS17-testDebugView.1.png index de3d4beef8..716b6469a6 100644 Binary files a/Tests/StoreKitUnitTests/Support/__Snapshots__/DebugViewSwiftUITests/iOS17-testDebugView.1.png and b/Tests/StoreKitUnitTests/Support/__Snapshots__/DebugViewSwiftUITests/iOS17-testDebugView.1.png differ diff --git a/Tests/StoreKitUnitTests/Support/__Snapshots__/DebugViewSwiftUITests/iOS17-testLoadingState.1.png b/Tests/StoreKitUnitTests/Support/__Snapshots__/DebugViewSwiftUITests/iOS17-testLoadingState.1.png index 35d478644e..440395c334 100644 Binary files a/Tests/StoreKitUnitTests/Support/__Snapshots__/DebugViewSwiftUITests/iOS17-testLoadingState.1.png and b/Tests/StoreKitUnitTests/Support/__Snapshots__/DebugViewSwiftUITests/iOS17-testLoadingState.1.png differ diff --git a/Tests/UnitTests/TestHelpers/SnapshotTesting+Extensions.swift b/Tests/UnitTests/TestHelpers/SnapshotTesting+Extensions.swift index ed4830ddaa..dba3b276b7 100644 --- a/Tests/UnitTests/TestHelpers/SnapshotTesting+Extensions.swift +++ b/Tests/UnitTests/TestHelpers/SnapshotTesting+Extensions.swift @@ -67,7 +67,7 @@ extension SwiftUI.View { controller ).toEventually( haveValidSnapshot( - as: .image(perceptualPrecision: 0.98, size: size), + as: .image(perceptualPrecision: 0.98, size: size, traits: traits), named: "1", // Force each retry to end in `.1.png` file: file, line: line @@ -78,6 +78,10 @@ extension SwiftUI.View { } } + +// Generate snapshots with scale 1, which drastically reduces the file size. +private let traits: UITraitCollection = .init(displayScale: 1) + #endif private let timeout: DispatchTimeInterval = .seconds(5)