---
title: "expectation(that:on:options:willSatisfy:)"
framework: xctest
role: symbol
role_heading: Instance Method
path: "xctest/xctestcase/expectation(that:on:options:willsatisfy:)-292oj"
---

# expectation(that:on:options:willSatisfy:)

Creates an expectation using key-value observing to monitor changes to a given key path on a given object.

## Declaration

```swift
func expectation<T, V>(that keyPath: KeyPath<T, V>, on observedObject: T, options: NSKeyValueObservingOptions = [.initial, .new, .old], willSatisfy filter: XCTKeyPathExpectation<T, V>.AsynchronousFilter? = nil) -> XCTKeyPathExpectation<T, V> where T : NSObject, T : Sendable, V : Sendable
```

## Parameters

- `keyPath`: The key path to observe.
- `observedObject`: The object to observe the key path on.
- `options`: Options to pass to Foundation when observing changes.
- `filter`: An asyncronous predicate function you use to test observed changes to a key path. If nil, the first observed change fulfills the expectation.

## Return Value

Return Value Creates and returns an expectation associated with the test case that a specific key-value observing (KVO) condition fulfills, see Using Key-Value Observing in Swift.

## See Also

### Creating Asynchronous Test Expectations

- [expectation(description:)](xctest/xctestcase/expectation(description:).md)
- [expectation(for:evaluatedWith:handler:)](xctest/xctestcase/expectation(for:evaluatedwith:handler:).md)
- [expectation(forNotification:object:handler:)](xctest/xctestcase/expectation(fornotification:object:handler:).md)
- [expectation(forNotification:object:notificationCenter:handler:)](xctest/xctestcase/expectation(fornotification:object:notificationcenter:handler:).md)
- [keyValueObservingExpectation(for:keyPath:expectedValue:)](xctest/xctestcase/keyvalueobservingexpectation(for:keypath:expectedvalue:).md)
- [expectation(that:on:options:willEqual:)](xctest/xctestcase/expectation(that:on:options:willequal:).md)
- [keyValueObservingExpectation(for:keyPath:handler:)](xctest/xctestcase/keyvalueobservingexpectation(for:keypath:handler:).md)
- [expectation(that:on:options:willSatisfy:)](xctest/xctestcase/expectation(that:on:options:willsatisfy:)-6itb.md)
- [expectation(that:on:options:willSatisfy:)](xctest/xctestcase/expectation(that:on:options:willsatisfy:)-85or0.md)
