Skip to main content
An assertion checks the screen and retries until it holds or the call’s timeout runs out (see call options). Then it fails with ASSERTION_FAILED, giving the expected and the actual value. So a test never has to wait for the app before checking it.
Every assertion resolves with the summaries of the matching elements. Most assertions about one element (text, value, label, focus, enabled, checked, props) need exactly one match; the ones that need it say so below. Each assertion also has a chained form, app.expect(target).toBe…().

Visibility and presence

expectVisible(target, options?)

Types: MatcherInput · VisibleOptions · ElementSummary Holds when at least one matching element is visible.

expectNotVisible(target, options?)

Types: MatcherInput · CallOptions · ElementSummary Holds when no matching element is visible: there is none, or it is hidden.

expectExists(target, options?)

Types: MatcherInput · CallOptions · ElementSummary Holds when a matching element is in the element tree, visible or not.

expectNotExists(target, options?)

Types: MatcherInput · CallOptions · ElementSummary Holds when no matching element is in the element tree.

expectCount(target, n, options?)

Types: MatcherInput · CallOptions · ElementSummary Holds when exactly n elements match.

Content

expectText(target, text, options?)

Types: MatcherInput · TextQuery · CallOptions · ElementSummary Holds when exactly one element matches and its text equals text, or matches it when text is a regular expression.

expectValue(target, value, options?)

Types: MatcherInput · JsonValue · CallOptions · ElementSummary Holds when exactly one element matches and its value equals value, or matches it when value is a regular expression. The value is the text of an input, the state of a switch, the value of a slider or picker, or the accessibilityValue.
A date / time picker’s value is what it shows, in the device’s local time: "2031-12-24" (mode date), "20:15" (time), "2031-12-24T20:15" (datetime), with seconds when they are not 0. A Date matches when those parts agree. See date and time pickers.

expectLabel(target, text, options?)

Types: MatcherInput · TextQuery · CallOptions · ElementSummary Holds when exactly one element matches and its accessibility label equals text, or matches it when text is a regular expression.

expectProp(target, prop, value, options?)

Types: MatcherInput · JsonValue · CallOptions · ElementSummary Holds when exactly one element matches and its prop prop has this JSON value. The host element’s props are looked at first, then those of its component (e.g. disabled, value).

State

expectEnabled(target, options?)

Types: MatcherInput · CallOptions · ElementSummary Holds when exactly one element matches and it is enabled.

expectDisabled(target, options?)

Types: MatcherInput · CallOptions · ElementSummary Holds when exactly one element matches and it is disabled.
An element is disabled through disabled, accessibilityState.disabled, aria-disabled or editable={false}, also when it inherits it from an ancestor.

expectChecked(target, options?)

Types: MatcherInput · CallOptions · ElementSummary Holds when exactly one element matches and it is checked: a switch, checkbox or radio, or any element with accessibilityState.checked.

expectNotChecked(target, options?)

Types: MatcherInput · CallOptions · ElementSummary Holds when exactly one element matches and it is unchecked.
An element without a checked state fails both expectChecked and expectNotChecked.

expectFocused(target, options?)

Types: MatcherInput · CallOptions · ElementSummary Holds when exactly one element matches and it has the input focus.

expectNotFocused(target, options?)

Types: MatcherInput · CallOptions · ElementSummary Holds when exactly one element matches and it does not have the input focus.

Chained form

expect(target)

Types: MatcherInput · ElementExpectation The same assertions in a chained form, like Detox and Jest. Both forms do the same thing: they wait for idle and retry until the assertion holds. Each method takes the call options as its last argument, and .not negates it.
A negated assertion about one element (not.toHaveText, not.toHaveValue, …) still needs exactly one match: it fails when there is none.