Skip to main content

Detox

Set up workflow to run Detox E2E tests for every Pull Request.

Learn more about Detox: wix.github.io/Detox

Usage

npx setup-ci --preset --detox

Detailed behavior

Below you can find detailed information about what the script does with your project when generating Detox workflow.

Installed dependencies

  • detox (dev)
  • jest (dev)
  • typescript (dev)
  • ts-jest (dev)
  • @types/jest (dev)
  • @config-plugins/detox (dev) (if project uses Expo)

Manual native code patch

If your project is not using Expo, you will have to manually patch the native code to make Detox work. SCI will provide you with the necessary instructions. Specifically, it will ask you to follow step 4 from Detox project setup.

Release build workflow

To test the app with Detox, we need to first build the app in release mode. Therefore, apart from CI workflow to run Detox tests, SCI will generate workflows for building the app, on which the Detox workflow depends. You can read more about the release build workflow in Release build.

Modified and created files

FileChanges
.github/workflows/test-detox-android.ymlContains the CI workflow for Detox on Android
.github/workflows/test-detox-ios.ymlContains the CI workflow for Detox on iOS
package.json
  • Missing dependencies are added
  • New script: detox:test:android: detox test --config-path .detoxrc-ci.js --configuration android.emu.release --cleanup
  • New script: detox:test:ios: detox test --config-path .detoxrc-ci.js --configuration ios.sim.release --cleanup
app.jsonAdd @config-plugins/detox to expo.plugins if project uses Expo (if app.config.js is detected instead, SCI will prompt you to add it manually)
.detoxrc-ci.jsCreated with Detox configuration for CI
e2e/jest.config.jsJest configuration for Detox, created if no e2e directory is detected
e2e/starter.test.tsExample Detox test, created if no e2e directory is detected

Workflow details

test-detox-android

The following diagram represents the flow of test-detox-android workflow:

test-detox-ios

The following diagram represents the flow of test-detox-ios workflow:

Known issues and limitations

  • Currently Detox tests are run on release builds. This means that the app will have to be built every time the code changes (native or JS). This can be time-consuming and if you would like to save this time, consider using Maestro workflow which is run on debug build. This allows for caching and rebuilding the app only if native code changes, which results in significant resource and time savings.