pointfreeco / swift-snapshot-testing

📸 Delightful Swift snapshot testing.

Home Page:https://www.pointfree.co/episodes/ep41-a-tour-of-snapshot-testing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Timeout Error During Snapshot Testing with WKWebView

stephan-vivie-rb opened this issue · comments

Environment

  • Xcode Version: 15.0.1
  • Swift Version: 5.9
  • SnapshotTesting Version: 1.14.0
  • iOS Version: 17.0.1
  • Devices/Emulators: iPhone 15 iOS 17.0.1

Description

We are experiencing a timeout error when performing snapshot tests on a UIViewController which contains a WKWebView. Our tests consistently fail with the following error message:

failed - Exceeded timeout of 5.0 seconds waiting for snapshot.

This can happen when an asynchronously rendered view (like a web view) has not loaded. Ensure that every subview of the view hierarchy has loaded to avoid timeouts, or, if a timeout is unavoidable, consider setting the "timeout" parameter of "assertSnapshot" to a higher value.

I have tried to increase the timeout but that doesn't help.

Is there a recommended approach for ensuring the WKWebView has fully rendered before the snapshot is taken? If that's not possible. It would be great just to be able to run the snapshot tests on the rest of the screen as the content of the WKWebView is out of our hands anyway, but the other elements on screen are not.