pointfreeco / swift-snapshot-testing

📸 Delightful Swift snapshot testing.
https://www.pointfree.co/episodes/ep41-a-tour-of-snapshot-testing
MIT License
3.76k stars 578 forks source link

Timeout Error During Snapshot Testing with WKWebView #805

Open stephan-vivie-rb opened 11 months ago

stephan-vivie-rb commented 11 months ago

Environment

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.