<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTWaiter/wait(for:timeout:)-swift.type.method",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:objc(cs)XCTWaiter(cm)waitForExpectations:timeout:"
  },
  "title" : "wait(for:timeout:)"
}
-->

# wait(for:timeout:)

Creates a waiter that waits on a group of expectations for up to the specified timeout.

```
class func wait(for expectations: [XCTestExpectation], timeout seconds: TimeInterval) -> XCTWaiter.Result
```

## Parameters

`expectations`

An array of expectations the test must satisfy.

`seconds`

The time, in seconds, the test allows for the fulfillment of the expectations. The default timeout allows the test to run until it reaches its execution time allowance.

## Return Value

A value describing the outcome of waiting for `expectations`.

## Discussion

Expectations can only appear in the array once. The test discards the waiter when the wait completes.

In Objective-C code, you might use an expectation to wait on a call to an interface that uses a completion handler to return a result. From Swift code, consider calling `withCheckedContinuation(function:_:)` to use <doc://com.apple.documentation/documentation/Swift/concurrency> instead of an expectation to wait on the result of a completion handler.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)