500Docs
  • React Libraries
  • SSR
  • React Native

›React Native

React Libraries

  • Calendar

Server-Side Rendering

  • Setup
  • Redux Integration

React Native

  • Tools
  • Setup (iOS)
  • Setup (Android)
  • Running a Project
  • Linking Libraries
  • Debugging
  • Appcenter
  • Detox
  • Bugsnag
  • Notifications
  • Routing
  • Splash Screen
  • RTL
  • Animations
  • Common Problems

Detox

Detox is a gray box end-to-end testing and automation library for mobile apps, developed by Wix.

iOS Installation

Follow Detox's documentation for iOS

Android Installation

Follow Detox's documentation for Android

Configuration

Add following detox config in your package.json:

"detox": {
  "configurations": {
    "ios.debug": {
      "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/${APP_NAME}.app",
      "build": "xcodebuild -workspace ios/HappyHour.xcworkspace -scheme ${DEBUG_SCHEME_NAME} -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
      "type": "ios.simulator",
      "name": "${IOS_SIMULATOR}"
    },
    "ios.release": {
      "binaryPath": "ios/build/Build/Products/Release-iphonesimulator/${APP_NAME}.app",
      "build": "xcodebuild -workspace ios/HappyHour.xcworkspace -scheme '${RELEASE_SCHEME_NAME}' -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
      "type": "ios.simulator",
      "name": "${IOS_SIMULATOR}"
    },
    "android.debug": {
      "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
      "build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
      "type": "android.emulator",
      "name": "${EMULATOR_NAME}"
    },
    "android.release": {
      "binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
      "build": "cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..",
      "type": "android.emulator",
      "name": "${EMULATOR_NAME}"
    }
  },
  "test-runner": "${TEST_RUNNER}"
}
  • Replace ${APP_NAME} with your iOS app's name
  • Replace ${DEBUG_SCHEME_NAME} & ${RELEASE_SCHEME_NAME} according to your schemes (see schemes guide)
  • Replace ${EMULATOR_NAME} with a name of the default emulator you want to open when running your tests (see emulators guide & the part about emulators in aliases)
  • Replace ${TEST_RUNNER} with "jest" or "mocha"
  • Replace ${IOS_SIMULATOR} with the default iOS simulator you want to open when running your tests ("iPhone 8"/"iPhone XS Max"...)

Add following lines to you package.json's scripts:

"test-ios": "detox test -c ios.debug",
"test-ios-release": "detox test -c ios.release",
"test-android": "detox test -c android.debug",
"test-android-release": "detox test -c android.release",

Artifacts

If you want the tests to also record application's screen when test fails, you could add these params:

--record-videos failing

Running tests

Run yarn test-ios/test-android, which will open a simulator, automatically run your tests with the interactions you've described, and close when done.

Last updated on 1/29/2019 by Vova Porton
← AppcenterBugsnag →
  • iOS Installation
  • Android Installation
  • Configuration
  • Artifacts
  • Running tests
Copyright © 2020 500Tech