From 3c82b1464c1ef95cdefc5aa77c6fc6c780da1e87 Mon Sep 17 00:00:00 2001 From: Felix Mau Date: Wed, 17 Aug 2022 22:50:03 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20Fix=20snapshot=20test?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GradientLoadingBarControllerTestCase.swift | 8 +++++--- .../NotchGradientLoadingBarControllerTestCase.swift | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Example/ExampleSnapshotTests/GradientLoadingBarController/GradientLoadingBarControllerTestCase.swift b/Example/ExampleSnapshotTests/GradientLoadingBarController/GradientLoadingBarControllerTestCase.swift index fb7dfdf..e04c2f8 100644 --- a/Example/ExampleSnapshotTests/GradientLoadingBarController/GradientLoadingBarControllerTestCase.swift +++ b/Example/ExampleSnapshotTests/GradientLoadingBarController/GradientLoadingBarControllerTestCase.swift @@ -39,7 +39,7 @@ final class GradientLoadingBarControllerTestCase: XCTestCase { let rootViewController = UIViewController() window.rootViewController = rootViewController - let expectation = expectation(description: "Expect view to be completely fade in.") + let expectation = expectation(description: "Expect view to be completely visible.") // When let gradientLoadingBarController = GradientLoadingBarController() @@ -48,7 +48,9 @@ final class GradientLoadingBarControllerTestCase: XCTestCase { } // Then - wait(for: [expectation], timeout: 0.1) - assertSnapshot(matching: window, as: .image) + wait(for: [expectation], timeout: 0.01) + + // Workaround, as snapshotting a `UIWindow` is currently not supported and crashes when running all tests. + assertSnapshot(matching: window.layer, as: .image) } } diff --git a/Example/ExampleSnapshotTests/GradientLoadingBarController/NotchGradientLoadingBarControllerTestCase.swift b/Example/ExampleSnapshotTests/GradientLoadingBarController/NotchGradientLoadingBarControllerTestCase.swift index e1c51f8..c2d9c6e 100644 --- a/Example/ExampleSnapshotTests/GradientLoadingBarController/NotchGradientLoadingBarControllerTestCase.swift +++ b/Example/ExampleSnapshotTests/GradientLoadingBarController/NotchGradientLoadingBarControllerTestCase.swift @@ -40,7 +40,7 @@ final class NotchGradientLoadingBarControllerTestCase: XCTestCase { let rootViewController = UIViewController() window.rootViewController = rootViewController - let expectation = expectation(description: "Expect view to be completely fade in.") + let expectation = expectation(description: "Expect view to be completely visible.") // When let gradientLoadingBarController = NotchGradientLoadingBarController() @@ -49,7 +49,9 @@ final class NotchGradientLoadingBarControllerTestCase: XCTestCase { } // Then - wait(for: [expectation], timeout: 0.1) - assertSnapshot(matching: window, as: .image) + wait(for: [expectation], timeout: 0.01) + + // Workaround, as snapshotting a `UIWindow` is currently not supported and crashes when running all tests. + assertSnapshot(matching: window.layer, as: .image) } }