React Native UI testing with Detox & Genymotion SaaS

Genymotion SaaS and Detox integration illustration.

Developing mobile applications in React Native has become more and more popular due to its cross-platform compatibility. To run end-to-end testing on React Native applications, Detox framework stands out:

  • it is fast and its asynchronous operations reduces testing flakiness
  • it integrates easily within the project code

As your application development code and features grow, there is a need to automate and scale those tests to reduce bugs as early as possible. Running those tests on virtual devices has an advantage : devices can be started and stopped on demand at scale.

To test your React Native application on Android, you could run them on Genymotion SaaS. It offers cloud-based Android Virtual Devices. Good news, Wix has been working on a tight integration with Genymotion SaaS to ease the run of end-to-end Detox testing for Android. The integration is not completely finished yet and made official but the core integration is already there. This tutorial is a teasing for a more detailed blogpost and documentation that Wix will release later once everything is completely integrated. For now, if you wish to test please follow these instructions.

There are different steps :

  1. Setup the devices to run the tests on
  2. Run the tests : devices are automatically started & stopped by detox

Requirements

Step 1: Setup Genymotion SaaS device

In your detox.config.js file, add android.genyclouddevice type. You can tell which device to start by giving its recipe uuid or its name.

For example:

with recipeUUID as the recipe uuid. You can refer to this example. The UUID can be retrieved using gmsaas recipes list command line. The comprehensive list of all currently available recipes UUIDs are available here

or

with recipeName as the name of the template to start. Please note that if several templates match the name, the first one of the list will be started. You can refer to this example.

Step 2: Setup Jest hooks

Detox automatically handles the start and stop of Genymotion devices with calls to global Detox init and cleanup callback in Jest’s hooks.

At project setup, init & teardown callbacks are automatically defined in jest config file like this:

Please make sure that globalSetup and globalTeardown callbacks are defined in the jest config file.

Step 3 [OPTIONAL]: Add an e2e script

If you wish to run your tests in parallel, add e2e script to run your tests in parallel in your package.json file:

"test:android-genycloud-release-ci":"detox test --configuration android.genycloud.release -l verbose --workers 2 --record-logs all --take-screenshots all

In this example it will start 2 devices and run the tests in parallel where android-genycloud-release is the final configuration of the device to run the tests. Please refer to this guide on how to configure a device. There is also an example here.

Step 4: Build your application

You should have a line like this in your package.json file

At the root of your project, run:

npm run build:android

Step 5: Run your tests

This will start the devices, run the tests and stop the devices:

npm run test:android-genycloud-release-ci

You can refer to the demo-react-native-jest project for a complete example.

At the end of this tutorial, you should be able to start and stop Genymotion SaaS virtual devices directly from your detox tests. You can also refer to Detox official documentation.

If you have any questions, feel free to contact us on our website, on Genymotion SaaS platform. To find more information, please read Genymotion SaaS documentation.

If you wish to contribute to the Detox project please go through the Contribution Guide.

Special thanks to Wix for doing an amazing job on the integration and to Amit and Yaroslav for reviewing the accuracy of the tutorial.

Table of Contents

Select Product Portal

SaaS Platform

Access to our SaaS solution and use virtual machines in the cloud on any web browsers.

Or

Or

Desktop Platform

Access to manage your Genymotion Desktop licenses, your invoices and account information.

Select a Cloud provider Marketplace

How to get a quote for multiple Business Licenses?

  1. You need a Genymotion Desktop account. If you haven’t one yet, you can create it here.
  2. After creation and activation, or if you already have an account, follow this link.
  3. Add the number of desired licenses to your shopping cart and click “Continue to Billing”
  4. Add a shipping address, or select one if you already created one.
  5.  In the next page, click “Get a quote”:
    Payment details
  6. A quote will be automatically generated in PDF format.

Genymotion Device Image for Cloud providers
- Private Offer -

Genymotion Device On-premise
- Contact Us -

Genymotion SaaS
- Increase Maximum Simultaneous devices -

Genymotion SaaS Enterprise Plan
- Get a Quote -

Genymotion SaaS Premium Plan
- Get a Quote -

Personal Use - Free

Genymotion Desktop for personal use is not suitable for trial or POC: you will not get any assistance and some features will be disabled. If you have already selected “personal use” and wish to get a trial license, please contact our Sales at [email protected].

Technical support is not available with Genymotion Desktop free edition for personal use. For more details, please refer to Genymotion conditions of use (Personal Use).

The following features are not available in personal use mode:

Follow these steps to get Genymotion Desktop and activate personal use mode:

  1. Go to the Download page and get the latest version for your system.
  2. Follow the instructions from Genymotion Desktop quickstart guide to install Genymotion Desktop.
  3. Launch Genymotion and click CREATE to create an account. You should receive an activation email within an hour. If not, make sure to check your spam.
  4. After activating your account, return to Genymotion and log in with your credentials.
  5. Select personal use when prompted.
  6. Read Genymotion Desktop quickstart guide carefully to setup Genymotion for your needs.

Indie Plan Application Form

This plan is strictly reserved to individual workers (freelancers, self-employed).

Educational Plan Application Form

The Educational plan is restricted to:

  • schools, teachers or students who wish to use Genymotion Desktop for tuition
  • students who wish to use Genymotion Desktop for a school project

It is subject to valid proof (student card, teacher card, etc.)