Nov 21, 2022
React Native Automation Testing Using Detox
With the help of detox, you can automate testing in React Native.
Author


Book a call
Table of Contents
What is Detox?
Detox is a JS-based end-to-end automation testing framework developed by Wix. Detox tests your mobile app while it's running on a real device or simulator, interacting with it just like an actual end user.
Issues with Appium
Appium is a popular mobile test automation framework that is often regarded as industry standard. Appium is based on black box testing, which simulates how an actual end user would interact with the app. In theory, this sounds great, but Appium tests are extremely unreliable. They frequently produce inconsistent results on different devices and are prone to frequent integration failures, resulting in slower tests.
Advantages of Detox
- Since Detox is based on “Grey Box” testing which means that the tester has some knowledge of the internal workings of the application and this allows the framework to monitor the app from within and synchronize with it. Not only Grey Box testing is more stable than Black Box testing, but it's also much faster.
- Detox does not rely on WebDriver and interacts directly with the native layers of the app
- It synchronizes with the app's activity i.e. it times its actions to run only when your app is idle, meaning it has determined that your app has finished work, such as React Native load, animations, network requests, etc.
- Relatively easy setup process and the tests are also quite simple, readable, and can even be shared between platforms.
Setting Up Detox
To get started with Detox, we’ll have to install the Detox command-line tools and the applesimutils library using the following commands.
$ yarn add --dev detox jest-circus$ detox init -r jestThis will create an e2e folder containing a few config files.
iOS Configuration
Detox for iOS does not require any additional setup; just go to the.detoxrc.json file and replace its content with the following: Make sure you replace "AppName” with the name of the app you have created.
$ detox build -c ios
Android Configuration
Change minSdkVersion to 18 and add kotlinVersion = "1.3.41" in the ext block.
Add the following configuration inside allprojects.repositories
Add the following two lines in android.defaultConfig block
Add the following lines in the dependencies section
Create a DetoxTest.java file at the following location: android/app/src/androidTest/java/com/reactnativedetox/DetoxTest.java and refer here for the contents of the file. Don’t forget to change the package name of the file to that of your own project.
android/app/src/main/res/xml
In the app's AndroidManifest.xml, add the following -
Step 5: Update .detoxrc.json
$ detox build -c android
Writing Your First Detox Test Case
Add a testID property to the component that you want to find, like this:
You can write test cases like this:
- Build on the specific platform you want to test using the above-mentioned build command.
- Run the tests
$ detox test -c android$ detox test -c iosNote: Starting with Xcode 9, Detox runs the iOS simulator in headless mode. If you are running the tests and the simulator does open up, then use Spotlight to pull up the simulator and hit enter, and it will bring all the simulators, detox has opened to the front.
Conclusion
- No support for expo
- Web Views are not supported; hence testing auth flows like Google, and Facebook is impossible. However, you can mock the external API to give you a predetermined auth token.
Subscribe to Our Newsletter
Subscribe to RSS
Press & Media Hub RSS FeedRelated Articles.
More from the engineering frontline.
Dive deep into our research and insights on design, development, and the impact of various trends to businesses.

Jun 17, 2026
Google I/O 2026 Mobile Playbook: AI Studio, Android CLI, and Antigravity for App Development

Jun 3, 2026
How US Fintech Companies Are Modernizing Legacy Banking Systems Without Full Rebuilds

May 14, 2026
Building a Production-Ready Image Cropper in React Native

Apr 14, 2026
The Keyboard Bounce of Death: Handling Inputs on Complex React Native Screens

Mar 3, 2026
Performant Vertical Feed in Expo: HLS Caching on iOS

Jan 27, 2026