Skip to content

RNTester Detox Android Setup

Yash Kumar Verma edited this page Jul 10, 2020 · 5 revisions

Prerequisite

  1. Move to the RNTester directory /packages/RNTester
  2. Run yarn install in the directory.

Running tests on Android simulator

  1. Make sure you have a emulator running. Check out this link for steps on creating and running an emulator using android studio.
  2. Edit the .detoxrc.json and insert your AVD name in place of YOUR_AVD_NAME.
  3. Run detox build -c android.emu.debug
  4. Run detox test -c android.emu.debug

Running tests on Physical device

  1. Make sure your device is running Android 5.0 (Lollipop) or newer and has USB debugging enabled, and it is connected via USB to your development machine.
  2. Run the command adb devices to see the list of all available devices.
  3. Run adb -s $YOUR_DEVICE_NAME reverse tcp:8081 tcp:8081 (replace $YOUR_DEVICE_NAME with the name you see in the list of connected devices after executing previous step)
  4. Edit the .detoxrc.json and insert your DEVICE name in place of YOUR_DEVICE_NAME.
  5. Run detox build -c android.emu.debug
  6. Run detox test -c android.emu.debug

Note - If you see some ERROR security exception INSTALL_GRANT_RUNTIME_PERMISSIONS while executing 8th step, change the connected device you are using (Some chinese company(MI, Oppo etc) phones do not support it)

The above tasks can be done using the https://github.com/YashKumarVerma/react-native-shots script.