Skip to content

Timeout Error During Snapshot Testing with WKWebView #805

@stephan-vivie-rb

Description

@stephan-vivie-rb

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions