Skip to main content
Version: Next

Preparing for CI


This guide is outdated.

When your test suite is finally ready, it should be set up to run automatically on your CI server on every git push. This will alert you if new changes to the app break existing functionality.

Running Detox on CI is not that different from running it locally. There are two main differences:

  • You should test a release build rather than a debug build
  • Tell Detox to shut down the simulator when test is over

Step 1: Prepare a Release Configuration for Your App

We will need to create a release app configuration for Detox – follow the previous tutorial if you haven’t completed it already.

Step 2: Add build and test Commands to Your CI Script

Assuming your CI is executing some sort of shell script, add the following commands that should run inside the project root:

detox build --configuration ios.sim.release
detox test --configuration ios.sim.release

Make sure to shut down the simulator when your tests are over.

Running Android Tests on CI

Setting up a CI environment capable of running Android tests isn’t as trivial.

Fortunately, we’ve written all about it in a blogpost on medium!

Also, check out the guide on how to prepare Android emulators for CI.


• Running Detox on Travis CI

Detox’s own build is running on Travis, check out Detox’s .travis.yml file to see how it’s done.

This is a simple example configuration to get you started with Detox on Travis:

language: objective-c
osx_image: xcode8.3

- master


- brew tap wix/brew
- brew install applesimutils
- curl -o- | bash
- export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/" ] && . "$NVM_DIR/"
- nvm install $NODE_VERSION
- nvm use $NODE_VERSION
- nvm alias default $NODE_VERSION

- npm install react-native-cli --global
- npm install detox-cli --global

- detox build --configuration ios.sim.release
- detox test --configuration ios.sim.release --cleanup

• Running Detox on Bitrise

Bitrise is a popular CI service for automating React Native apps. If you are looking to get started with Bitrise, check out this guide.

You can run Detox on Bitrise by creating a new workflow. Below is an example of the Bitrise .yml file for a workflow called tests.

Additionally, you can use a webhook on Bitrise to post the build status directly into your Slack channel.

format_version: 1.1.0
- push_branch: "*"
workflow: tests
- activate-ssh-key: {}
- git-clone:
- clone_depth: ''
title: Git Clone Repo
- script:
- content: |-

npm cache verify

npm install
title: Install NPM Packages
before_run: []
after_run: []
- npm:
- command: install -g detox-cli
title: Install Detox CLI
- npm:
- command: install -g react-native-cli
title: Install React Native CLI
- script:
- content: |-

brew tap wix/brew
brew install applesimutils
title: Install Detox Utils
- script:
- content: |-

detox build --configuration ios.sim.release
title: Detox - Build Release App
- script:
- content: |-

detox test --configuration ios.sim.release --cleanup
title: Detox - Run E2E Tests
- _tests_setup
- _detox_tests
after_run: []

• Running Detox on GitLab CI - Android Only

GitLab is also a popular git management service which also include a built-in CI system. They provide free runner up to 2000 minutes for private projects, however, the runners provided by them cannot be used to run Detox due to the lack of KVM support (in order to run Android Emulators). You can, instead, create your own runner with KVM support. Some example of cloud providers offering this are: Digital Ocean, AWS (with C5 instance types), Google Cloud and Azure

One example of such job can be:

stage: test
image: reactnativecommunity/react-native-android
- npm install envinfo detox-cli --global && envinfo
# Increase file watcher limit, see more here:
- echo fs.inotify.max_user_watches=524288 | tee -a /etc/sysctl.conf && sysctl -p
- mkdir -p /root/.android && touch /root/.android/repositories.cfg
# The Dockerimage provides two paths for sdkmanager and avdmanager, which the defaults are from $ANDROID_HOME/cmdline-tools
# That is not compatible with the one that Detox is using ($ANDROID_HOME/tools/bin)
- echo yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --channel=0 --verbose "system-images;android-27;default;x86_64" "emulator"
# Nexus 6P, API 27, XXXHDPI
- echo no | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager --verbose create avd --force --name "Nexus6P" --package "system-images;android-27;default;x86_64" --sdcard 200M --device 11
- adb start-server
- npx detox build -c
- npx detox test -c --headless