githubEdit

React Native Support

Maestro supports testing React Native apps on Android and iOS. Learn how to interact with components by text or testID, input text, and run sample UI tests.

Maestro supports testing React Native screens and apps on both Android and iOS.

Interacting with a component by Text

Maestro can interact with components that display text.

Example: Tap on a Button

For the Button component definition:

The following command will tap on the Button:

Interaction with a component by testID

Maestro can interact with components that have a testID.

Example: Tap on a button with a testID property

For the Button component definition:

The following command will tap on the Button:

Entering text in a Text Input

Example: Enter text into a TextInput.

To input text to a TextInput component, first the component needs to be selected. This can be done using the tapOn command. For the component definition:

The following commands will enter "Hello, Maestro!" in the TextInput component:

Create a working sample app with Maestro tests

Install Maestro

Maestro install instructionsarrow-up-right

Create a sample app

Follow the Expo Go Quickstart instructions on React Native environment setuparrow-up-right

Replace the contents of App.js with:

Create a test definition file called flow.yaml

Add the following contents:

Start the app and test using Maestro

Run npm start in the react native app source directory

Select either Android or iOS Simulator

In another terminal, run maestro test flow.yaml

When the Expo app launches, select the app that you’re testing

Demo

React Native app tested using Maestro

Interacting with nested components on iOS

In some cases, you may run into issues with nested tappable / accessible elements on iOS. You can resolve these issues by enabling accessibility for the inner component and disabling it for the outer container.

Example: Tapping on nested Text Component

The following command will tap on the nested Text Component:

Resources

Last updated

Was this helpful?