Contents

AppIntentExpectation

An expectation that checks an app intent’s parameters and, optionally, the result the intent returns.

Declaration

struct AppIntentExpectation

Overview

Use an app intent expectation to declare what you expect of an intent before you have one, then check an intent against it or pass it to a framework that takes intent expectations. The expectation checks only the parameters you specify, and checks the result only when you add a result expectation. Checking an expectation doesn’t perform the intent.

You don’t create an app intent expectation directly. Call expect or result(_:) on an intent definition, and optionally call result(_:) to add an expectation on the result. To check an intent and its result, call isSatisfied(by:result:):

let expectation = createEventIntentDefinition
    .expect(title: .contains("NASA"))
    .result(eventEntityDefinition)

let result = try await intent.run()
let isSatisfied = try await expectation.isSatisfied(
    by: intent,
    result: result
)

Topics

Instance Methods