DEV Community

Test your React Native app with Maestro

Alexander Hodes on December 22, 2022

Testing is always something that's important in app development, but often it's still done manually by testers or developers. Sometimes it can occu...
Collapse
 
retyui profile image
Davyd NRB

That is untreatable! Definitely, I want to move away from Appium.

Do you know how we can launch app with custom arguments?

// Appium api (see: http://appium.io/docs/en/writing-running-appium/caps/)
capabilities: {
  optionalIntentArguments: `--ez myBool true --es myStr 'string text'`, // Android
  processArguments: {args : ['-myBool', 'true','-myStr', 'string text']}, // iOS
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
alexanderhodes profile image
Alexander Hodes

Sounds great, I can really recommend Maestro.
You can use the parameters from maestro, e.g.

maestro test -e myBool=true -e myStr =string .maestro/flow.yaml
Enter fullscreen mode Exit fullscreen mode

You can access those external parameters like this in your workflow file:

${USERNAME}
Enter fullscreen mode Exit fullscreen mode

You can find an example workflow file with external parameters here github.com/alexanderhodes/react-na...
And I can recommend the documentation about parameters in the maestro docs maestro.mobile.dev/advanced/parame...

Collapse
 
retyui profile image
Davyd NRB

No you don't understood. I need support of launchArguments to access them inside my app (not inside e2e flow)

usigin a github.com/iamolegga/react-native-... module

Collapse
 
jakecarpenter profile image
Jake Carpenter

Thank you for the post! I'm playing with this myself now because Appium has way too many problems.

What are the options for infrastructure to run Maestro? Is it currently only their Maestro Cloud? What about physical device support?

Collapse
 
alexanderhodes profile image
Alexander Hodes

You can easily run it on their cloud, because they provide their a dashboard for your historical runs as well.

And you can run it on every infrastructure as well. You just need to install the CLI and the dependencies for the simulator or emulator. It's just a combination of installing the CLI like here.

Furthermore, you can run it on physical devices as well. On Android it works out of the box after connecting your device and for iOS device you need to install the Facebook IDB tool. The installation is described here: maestro.mobile.dev/getting-started...

And here you can find some notes about running it on physical devices. maestro.mobile.dev/getting-started...

Collapse
 
tiaeastwood profile image
Tia Eastwood

Thanks for this, I've just started using maestro and this has some useful examples

Collapse
 
retyui profile image
Davyd NRB • Edited

Will be great to add that all MAESTRO_* env variabled will be available in flow without passing them as -e MY_VAR=myVal

export MAESTRO_USERNAME=123

maestro test .maestro/flow.yaml
Enter fullscreen mode Exit fullscreen mode

and then

${MAESTRO_USERNAME} # 123

Collapse
 
retyui profile image
Davyd NRB

Another cool feature that have to mentioned it is conditions

- runFlow:
    when:
      visible: Password is required
    commands:
      - tapOn: "Enter password"
      - inputText: "my password"

# or 

- runFlow:
    env:
      true: ${IS_IOS == 'true'}
    commands:
      - tapOn: Delete Account
Enter fullscreen mode Exit fullscreen mode
Collapse
 
marcocadei_95 profile image
Marco Cadei

How do you create the .app file for a ReactNative app so that it doesn't require Maestro?

Collapse
 
tilak profile image
Tilak Vattikuti

How to run on my local real devices (actual mobile devices) instead of virtual devices

Collapse
 
vasylnahuliak profile image
Vasyl Nahuliak

At the moment, Maestro does not support real iOS devices

maestro.mobile.dev/getting-started...

Android - maestro test will automatically detect and use any local emulator or USB-connected physical device.

Collapse
 
jay_kahn_yz profile image
Jay Kahn

Thanks for the info. Any timeframe about when maestro will be able to run on real iOS device. Thanks