Overview
Detox is an open-source end-to-end testing and automation framework specifically engineered for mobile applications. It supports applications built with React Native, as well as native iOS and Android applications. Developed and maintained by Wix.com, Detox was founded in 2016 to address the challenges of testing complex mobile user interfaces reliably. Its core principle is a "gray box" testing approach, which means tests run directly on a physical device or emulator and interact with the application using a low-level API, similar to how a user would. This differs from pure "black box" testing, where only external interfaces are tested, and "white box" testing, which involves detailed knowledge of internal code structures.
The framework is designed to provide stable and deterministic test results by synchronizing with the application's internal state. This synchronization helps prevent common flaky test issues that arise from asynchronous operations, animations, or network requests. Detox automatically waits for the application to be idle before executing the next test command, ensuring that UI elements are in a predictable state. This characteristic makes it suitable for integration into continuous integration (CI) pipelines, where consistent and repeatable test outcomes are critical for rapid feedback on code changes.
Detox is primarily used by developers and QA engineers who need to validate the full user flow of a mobile application, from login to complex feature interactions. It is particularly valuable for React Native projects due to its deep integration with the framework, but its capabilities extend to native mobile development, making it a versatile tool for ensuring UI quality across different mobile technology stacks. The framework's API allows for expressive test writing using JavaScript or TypeScript, often integrated with the Jest testing framework for assertions and test runner capabilities.
While Detox focuses on end-to-end testing, it operates at a lower level than some other cross-platform testing tools, directly manipulating the UI and observing application behavior on the device itself. This direct interaction helps confirm that the app behaves as expected in a real-world environment, including interactions between native modules and JavaScript code in React Native applications. Its architecture is detailed in its official documentation, emphasizing its ability to bypass certain limitations of traditional UI testing by operating within the app's process where possible, especially on iOS platforms.
Key features
- Gray-box testing approach: Executes tests directly on the device or emulator, allowing for interaction with the app's UI elements and internal state. This approach provides more reliable results than pure black-box testing by synchronizing with the app's readiness to interact (Detox documentation on getting started).
- Automatic synchronization: Waits for the application to be idle (e.g., no pending network requests, animations, or UI updates) before proceeding with test actions, reducing test flakiness and improving reliability.
- Platform support: Specifically designed for testing React Native applications, as well as native iOS and Android applications.
- JavaScript/TypeScript API: Allows tests to be written in JavaScript or TypeScript, integrating seamlessly with popular testing frameworks like Jest.
- Element matching and actions: Provides a rich API for locating UI elements by ID, text, type, or other properties, and performing actions such as tapping, typing, scrolling, and swiping (Detox API reference for matchers).
- Mocking capabilities: Supports mocking network requests and other external dependencies, enabling isolated testing of UI logic without relying on backend services.
- Screenshot and video recording: Offers features to capture screenshots and record videos of test runs, aiding in debugging and test failure analysis.
- Continuous Integration (CI) friendly: Designed for easy integration into CI/CD pipelines, providing fast and consistent feedback on mobile app changes.
- Hermetic tests: Aims to create hermetic tests, meaning tests are isolated and repeatable, producing the same results regardless of external factors or the order of execution.
Pricing
Detox is an open-source project released under the MIT License and is free to use. There are no licensing fees, subscription costs, or commercial tiers associated with the framework itself. Users can access the source code, contribute to its development, and utilize all features without charge.
| Feature | Cost (as of 2026-05-07) | Details |
|---|---|---|
| Detox Framework | Free | Fully open source under the MIT License. No commercial tiers or paid features. |
| Community Support | Free | Support available via GitHub issues and community forums. |
Common integrations
- Jest: Detox is commonly integrated with Jest, a JavaScript testing framework, for writing and running tests, structuring assertions, and managing test suites. Jest provides the test runner and assertion library (Detox project setup guide).
- React Native: As a primary target, Detox integrates deeply with React Native projects, requiring native module linking for both iOS and Android components to operate effectively.
- Xcode: For iOS development, Detox leverages Xcode build tools and simulators to run tests on iOS devices and emulators.
- Android Studio/Gradle: On Android, Detox interacts with Android Studio's build system (Gradle) and emulators/devices for executing tests.
- CI/CD platforms: Detox is designed for integration with various continuous integration and continuous delivery platforms such as GitHub Actions, GitLab CI, Jenkins, and Azure DevOps to automate mobile app testing workflows.
- Native Module Linking: For React Native applications, Detox requires specific native module linking steps for both iOS and Android to enable the framework to communicate with the application under test (React Native documentation on iOS linking).
Alternatives
- Appium: An open-source test automation framework for native, hybrid, and mobile web apps, offering cross-platform support with a single API. Appium supports various programming languages for writing tests.
- Cypress: A JavaScript-based end-to-end testing framework primarily for web applications. While not focused on native mobile, it can test web views within hybrid apps.
- Playwright: A Node.js library to automate Chromium, Firefox, and WebKit with a single API. Like Cypress, it is primarily for web applications but can be used for testing web content within mobile browsers or hybrid apps.
Getting started
To begin using Detox, you typically install it as a development dependency in your project and configure it for your specific mobile platform. The following example demonstrates a basic setup for a React Native project, including installation and a simple test case. This assumes you have a React Native project already set up and Node.js installed.
# Install Detox and Jest
npm install detox jest --save-dev
# Initialize Detox in your project
detox init -r jest --no-eslint
After initialization, Detox creates a .detoxrc.js configuration file and a e2e directory for your tests. You'll need to follow specific setup steps for iOS and Android, which involve modifying native project files to integrate the Detox test runner. For instance, on iOS, this often means adding a new test target in Xcode.
Here's an example of a simple Detox test in JavaScript, located in e2e/firstTest.e2e.js:
describe('Example', () => {
beforeAll(async () => {
await device.launchApp();
});
beforeEach(async () => {
await device.reloadReactNative();
});
it('should have welcome screen', async () => {
await expect(element(by.id('welcome'))).toBeVisible();
});
it('should show hello screen after tap', async () => {
await element(by.id('hello_button')).tap();
await expect(element(by.text('Hello!!!'))).toBeVisible();
});
it('should show world screen after tap', async () => {
await element(by.id('world_button')).tap();
await expect(element(by.text('World!!!'))).toBeVisible();
});
});
To run these tests, you first need to build your Detox test target. This command builds the test runner for the specified configuration (e.g., ios.sim.debug for an iOS simulator debug build):
detox build --configuration ios.sim.debug
Then, you can run the tests:
detox test --configuration ios.sim.debug
This command launches the simulator (if not already running), installs the built application, and executes the tests. The device.launchApp() and device.reloadReactNative() commands manage the application's lifecycle during the test run, ensuring a clean state for each test suite.