Search code examples
androiddetox

Problem with running emulator with Detox: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected


I have Detox tests successfully being built and running on an iOS Simulator. I have Detox successfully building for Android, but when attempting to run the tests, I see the app launch and then error because the DetoxServer is unable to forward. The test shows it is unassigned. I believe it should be assigned to the device or emulator ID.

To Reproduce

Run the following command: yarn run detox test -c android.emu.release --loglevel trace

Environment

  • Detox: ^14.5.1
  • React Native: 0.60.5
  • Node: ^8.3 || >=10.*
  • Device: emulator-15018 device
  • OS: API 28

Verbose Detox Logs

detox[70981] TRACE: [exec.js/EXEC_SUCCESS, #17] u0_a106      29575  1934 1452728 123920 0                   0 S com.app_name.app

detox[29575] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onLaunchApp({ deviceId: 'emulator-15018',
  bundleId: 'com.app_name.app',
  launchArgs:
   { detoxServer: 'ws://localhost:50780',
     detoxSessionId: 'beebae37-5672-7400-eb92-e9f14ad9b594' },
  pid: 29575 })
detox[70981] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"isReady","params":{},"messageId":-1000}
detox[70981] TRACE: [DetoxServer.js/MESSAGE] role=tester action=isReady (sessionId=beebae37-5672-7400-eb92-e9f14ad9b594)
detox[70981] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=beebae37-5672-7400-eb92-e9f14ad9b594)
A test to validate the Login page assigned to undefined

Solution

  • I have an open issue with Detox for this problem, but a temporary solution seems to be to set android/build.gradle with this:

    buildscript {
        ext {
            targetSdkVersion = 27
        }
    }
    

    and then use an emulator on API 27 to run.