4

I am using detox for testing my RN application

I have a stub for Facebook login in tests like this:

// js/actions/login.e2e.js

function fbAuth() {
  console.log('stubbed auth with Facebook');
}

module.exports = { fbAuth };

When I build my app with RN_SRC_EXT=e2e.js react-native run-android and then run the tests detox test -c android.emu.debug it uses file with the stub

When I build my app with react-native run-android and then run the tests it uses non-stub version (real login with Facebook)

My detox config looks as follows

 "detox": {
    "configurations": {
      "android.emu.debug": {
        "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
        "build": "cd android && RN_SRC_EXT=e2e.js ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
        "type": "android.emulator",
        "name": "Android_Accelerated_Nougat"
      }
    }
  }

The question is: how can I configure detox to use *e2e.js files in tests without running RN_SRC_EXT=e2e.js react-native run-android before starting the tests?

I've tried

RN_SRC_EXT=e2e.js node_modules/.bin/mocha e2e --opts e2e/mocha.opts --configuration android.emu.debug --grep :ios: --invert

RN_SRC_EXT=e2e.js detox test -c android.emu.debug

but it didn't help

UPDATE:

Actually RN_SRC_EXT=e2e.js react-native run-android doesn't help: I need to stop my Metro process and run RN_SRC_EXT=e2e.js react-native run-android to force RN to use e2e.js files in the test bundle

Hirurg103
  • 4,783
  • 2
  • 34
  • 50

0 Answers0