Skip to content

An example project for React Native & Redux tested with e2e tool Detox

Notifications You must be signed in to change notification settings

eric-crowell/react-native-redux-e2e

Repository files navigation

React Native Redux E2E

An example React Native project for Redux Toolkit CI that runs Detox end-to-end tests against a Metro bundler build.

App Screenshot

How to Setup Locally

  1. Clone the project git clone
  2. Install dependencies yarn install
  3. Setup a local Pixel 3a API 30 Android Virtual Device.
  4. Start the Pixel 3a API 30 Virtual Device
  5. Install the release packages with yarn adb:install (after virtual device has started)
  6. Redirect ADB ports to local mock server with yarn adb:redirect
  7. Run tests yarn test

After developing, to rerun the tests...

  1. Build new APK apps with yarn build
  2. Install the release packages with yarn adb:install
  3. Run the tests: yarn test

Notes

Jest Tests

The tests run with jest since Detox supplies setup and takedown scripts compatible with that tool. It might be possible to run with vitest with more experimentation and custom configurations/scripts.

Android Device

The project uses Android emulation to run the Metro bundle. It is the most widely compatible for local development.

GitHub MacOS Runner

Android Debug Bridge (ADB) service for emulation does not reliably run on Ubuntu Linux (from experience); therefore, MacOS is the preferred runner. Not sure if it's due to how reactivecircus/android-emulator-runner@v2 is setup or something else.

Self installing APK

Letting Detox handle the installation of the APK app on emulator results in the following error in the workflow...

ChildProcessError: '/Users/runner/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell pm install -r -g -t /data/local/tmp/detox/Application.apk' failed with code null

The solution is to install the APK app in the emulator before running the Detox tests. This is the purpose of the yarn adb:install and yarn adb:install:test scripts.

ADB Process Errors

In the GitHub Action workflow, there'll be a repeating output of...

/Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
adb: device offline

This is normal. The action is waiting on the emulator to boot.

Average Run Time

Without cache on the first run, the workflow takes about 30 - 40 minutes to complete. With all cache, the workflow takes about 10 - 15 minutes.

About

An example project for React Native & Redux tested with e2e tool Detox

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published