Skip to main content
Version: Next


Detox uses matchers to match UI elements in your app and expectations to verify those elements are in the expected state.

Use actions to simulate use interaction with elements.



Expects the view to be at least N% visible on the screen. Accepts an optional parameter of percent threshold of element visibility, integer ranging from 1 to 100, that determines whether the element is visible or not. If no number is provided then defaults to 75%.

Negating this expectation with a not expression expects the view’s visible area to be lower than N%.

On iOS, visibility is defined by having the view, or one of its subviews, be topmost at the view’s activation point on screen.

await expect(element('subtitle'))).toBeVisible();
await expect(element('mainTitle'))).toBeVisible(35);


Expects the element to exist within the app’s current UI hierarchy.

await expect(element('okButton'))).toExist();


Expects the element to be the focused element.

await expect(element('emailInput'))).toBeFocused();


Expects the element to have the specified text.

await expect(element('mainTitle'))).toHaveText('Welcome back!');


Expects the element to have the specified label as its accessibility label (iOS) or content description (Android). In React Native, this corresponds to the value in the accessibilityLabel prop.


Note that in React Native apps, the accessibilityLabel is computed in a non-standard way, which happens to differ between iOS and Android. Detox bridges over that gap by artificially aligning Android to iOS. Effectively, that means that in React Native apps, performing accessibility-label based matching for elements with no explicit label suggests that the matching will be performed against a concatenation of labels from the child-elements, if applicable. For example:

<View testID='title-root'>
<Text accessibilityLabel={'title'}>Goodbye!</Text>
<Text accessibilityLabel={'subtitle'}>Thanks for all the fish.</Text>

In this case, where title-root has no accessibility label of its own, matching the label of title-root will be performed against the text: title subtitle.

Also note that in iOS, accessibilityLabel for primitive elements such as text, automatically receives the text itself - even if the accessibilityLabel prop isn't explicitly specified.

await expect(element('submitButton'))).toHaveLabel('Submit');


Expects the element to have the specified accessibility identifier. In React Native, this corresponds to the value in the testID prop.

await expect(element(by.text('Submit'))).toHaveId('submitButton');


Expects the element to have the specified accessibility value. In React Native, this corresponds to the value in the accessibilityValue prop.

await expect(element('temperatureDial'))).toHaveValue('25');

toHaveSliderPosition(normalizedPosition, tolerance)

Expects the slider element to have the specified normalized position ([0, 1]), within the provided tolerance (optional).

await expect(element('slider'))).toHaveSliderPosition(0.75);
await expect(element('slider'))).toHaveSliderPosition(0.3113, 0.00001);


Expects a toggle-able element (e.g. a Switch or a Check-Box) to be on/checked or off/unchecked. As a reference, in react-native, this is the equivalent switch component.

await expect(element('switch'))).toHaveToggleValue(true);
await expect(element('checkbox'))).toHaveToggleValue(false);


Waits until the expectation is resolved for the specified amount of time. If timeout is reached before resolution, the expectation is failed.

timeout—the timeout to wait, in ms

await waitFor(element('bigButton'))).toBeVisible().withTimeout(2000);



Negates the expectation, e.g.:

await expect(element('tinyButton'))).not.toBeVisible();
await expect(element('tinyButton'))).not.toExist();
await expect(element('tinyButton'))).not.toBeFocused();
await expect(element('tinyButton'))).not.toHaveText('');
await expect(element('tinyButton'))).not.toHaveValue('');