result(_:)
Creates an intent expectation that checks the result the intent returns, but none of its parameters.
Declaration
func result(_ resultExpectation: any IntentValueExpectation) -> AppIntentExpectationParameters
- resultExpectation:
The value expectation for the intent’s result, such as an Appentityexpectation. Pass Isnil to expect no result.
Return Value
An intent expectation that checks only the intent’s result.
Discussion
To check the result, perform the intent and pass both the intent and its result to isSatisfied(by:result:). If you omit the result, the framework treats the intent as returning no value. For example:
let createEventIntentDefinition = definitions.intents["CreateEventIntent"]
let intent = createEventIntentDefinition.makeIntent(title: "NASA launch")
let result = try await intent.run()
let expectation = createEventIntentDefinition.result(.notNil)
let isSatisfied = try await expectation.isSatisfied(
by: intent,
result: result
)