Detox: cannot be cast to com.facebook.react.ReactApplication

Describe the bug

After running detox test -c android.emu.debug it launches the app in the emulator extremely briefly and then crashes immediately. Looking at the Logcat, I see the following error:

03-21 11:19:25.059 4118-4156/com.insightemissions.trak.debug E/AndroidRuntime: FATAL EXCEPTION: com.wix.detox.manager
    Process: com.insightemissions.trak.debug, PID: 4118
    java.lang.ClassCastException: com.insightemissions.trak.CNTRAL cannot be cast to com.facebook.react.ReactApplication
        at com.wix.detox.ReactNativeSupport.getInstanceManager(ReactNativeSupport.java:64)
        at com.wix.detox.ReactNativeSupport.waitForReactNativeLoad(ReactNativeSupport.java:118)
        at com.wix.detox.ReactNativeCompat.waitForReactNativeLoad(ReactNativeCompat.java:33)
        at com.wix.detox.DetoxManager.initReactNativeIfNeeded(DetoxManager.java:121)
        at com.wix.detox.DetoxManager.start(DetoxManager.java:66)
        at com.wix.detox.Detox$1$1.run(Detox.java:133)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at com.wix.detox.Detox$1.run(Detox.java:136)
        at java.lang.Thread.run(Thread.java:818)

Screenshots Mar-21-2019 11-25-28

Screenshot 2019-03-21 11 26 01

Environment (please complete the following information):

  • Detox: 11.0.2
  • React Native: 0.57.8
  • Node: 10.11.0
  • Device: Mac Pro / Android Emulator (API 22)
  • OS: macOS 10.13.6

Device and Verbose Detox Logs

cntral_mobile $ node_modules/.bin/detox test -c android.emu.debug --loglevel verbose
configuration="android.emu.debug" loglevel="verbose" artifactsLocation="artifacts/android.emu.debug.2019-03-21 17-28-27Z" node_modules/.bin/jest "e2e" --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:ios:).)*$' 
detox[50428] INFO:  [DetoxServer.js] server listening on localhost:51770...
detox[50428] DEBUG: [AsyncWebSocket.js/WEBSOCKET_OPEN] opened web socket to: ws://localhost:51770
detox[50428] DEBUG: [DetoxServer.js/LOGIN] role=tester, sessionId=d15ff434-a7ff-5eee-fd8f-506fef1ee04f
detox[50428] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=tester, sessionId=d15ff434-a7ff-5eee-fd8f-506fef1ee04f
detox[50428] DEBUG: [exec.js/EXEC_CMD, #0] /Users/me/Library/Android/sdk/emulator/emulator -list-avds --verbose
detox[50428] DEBUG: [exec.js/EXEC_CMD, #1] /Users/me/Library/Android/sdk/platform-tools/adb  devices
detox[50428] DEBUG: [exec.js/EXEC_CMD, #2] /Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "getprop dev.bootcomplete"
detox[50428] DEBUG: [exec.js/EXEC_CMD, #3] /Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "getprop ro.build.version.sdk"
detox[50428] DEBUG: [exec.js/EXEC_CMD, #4] /Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "dumpsys power | grep \"^[ ]*m[UW].*=\""
detox[50428] DEBUG: [exec.js/EXEC_CMD, #5] /Users/me/Library/Android/sdk/build-tools/28.0.3/aapt dump badging "/Users/me/Development/app/cntral/build/outputs/apk/debug/cntral-debug.apk" | grep -e "package: name="
detox[50428] DEBUG: [exec.js/EXEC_CMD, #6] /Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "pm list packages com.insightemissions.trak.debug"
detox[50428] DEBUG: [exec.js/EXEC_CMD, #7] /Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 uninstall com.insightemissions.trak.debug
detox[50428] DEBUG: [exec.js/EXEC_CMD, #8] /Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "pm list packages com.insightemissions.trak.debug.test"
detox[50428] DEBUG: [exec.js/EXEC_CMD, #9] /Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 uninstall com.insightemissions.trak.debug.test
detox[50428] DEBUG: [exec.js/EXEC_CMD, #10] /Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 install -rg /Users/me/Development/app/cntral/build/outputs/apk/debug/cntral-debug.apk
detox[50428] DEBUG: [exec.js/EXEC_CMD, #11] /Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 install -rg /Users/me/Development/app/cntral/build/outputs/apk/androidTest/debug/cntral-debug-androidTest.apk
detox[50428] DEBUG: [exec.js/EXEC_CMD, #12] /Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "am force-stop com.insightemissions.trak.debug"
detox[50428] DEBUG: [exec.js/EXEC_CMD, #13] /Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "pm list instrumentation"
detox[50428] DEBUG: [exec.js/SPAWN_CMD, #14] [pid=50449] /Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell am instrument -w -r "-e detoxServer ws://localhost:51770 -e detoxSessionId d15ff434-a7ff-5eee-fd8f-506fef1ee04f" -e debug false com.insightemissions.trak.debug.test/androidx.test.runner.AndroidJUnitRunner
detox[50428] DEBUG: [exec.js/EXEC_CMD, #15] /Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell "ps | grep \"com\.insightemissions\.trak\.debug$\""
detox[50428] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=d15ff434-a7ff-5eee-fd8f-506fef1ee04f)
detox[50428] DEBUG: [exec.js/KILL] sending SIGINT to [pid = 50449]: /Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell am instrument -w -r -e detoxServer ws://localhost:51770 -e detoxSessionId d15ff434-a7ff-5eee-fd8f-506fef1ee04f -e debug false com.insightemissions.trak.debug.test/androidx.test.runner.AndroidJUnitRunner
 FAIL  e2e/firstTest.spec.js (21.593s)
  Example
    ✕ should have CNTRAL logo (27ms)

  ● Example › should have CNTRAL logo

    Timeout - Async callback was not invoked within the 20000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 20000ms timeout specified by jest.setTimeout.

      at mapper (../node_modules/jest-jasmine2/build/queueRunner.js:25:45)

  ● Example › should have CNTRAL logo

    ReferenceError: element is not defined

       5 |   } );
       6 | 
    >  7 |   it( "should have CNTRAL logo", async () => {
         |                                  ^
       8 |     console.log( "test1" );
       9 |     await expect( element( by.id( "cntral_logo" ) ) ).toBeVisible();
      10 |   } );

      at _callee2$ (firstTest.spec.js:7:34)
      at tryCatch (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:62:40)
      at Generator.invoke [as _invoke] (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:288:22)
      at Generator.prototype.(anonymous function) [as next] (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:114:21)
      at tryCatch (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:62:40)
      at invoke (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:152:20)
      at ../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:187:11
      at callInvokeWithMethodAndArg (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:186:16)
      at AsyncIterator.enqueue (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:209:13)
      at AsyncIterator.prototype.(anonymous function) [as next] (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:114:21)
      at Object.<anonymous>.runtime.async (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:233:14)
      at Object._callee2 (firstTest.spec.js:7:34)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        21.646s, estimated 22s
Ran all test suites matching /e2e/i with tests matching "^((?!:ios:).)*$".
detox[50428] DEBUG: [DetoxServer.js/DISCONNECT] role=tester, sessionId=d15ff434-a7ff-5eee-fd8f-506fef1ee04f
  console.log e2e/firstTest.spec.js:3
    test1 beforeEach

  console.log e2e/firstTest.spec.js:8
    test1

  console.log e2e/init.js:17
    afterAll

child_process.js:651
    throw err;
    ^

Error: Command failed: node_modules/.bin/jest "e2e" --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:ios:).)*$' 
    at checkExecSyncError (child_process.js:611:11)
    at Object.execSync (child_process.js:648:13)
    at runJest (/Users/me/Development/app/node_modules/detox/local-cli/detox-test.js:170:6)
    at run (/Users/me/Development/app/node_modules/detox/local-cli/detox-test.js:88:7)
    at Object.<anonymous> (/Users/me/Development/app/node_modules/detox/local-cli/detox-test.js:233:1)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

Is Detox still not able to support testing against native Android UI components? We’re currently evaluating Detox usage, but have an incredibly large platform to support, and not supporting native Android UI testing is close to being a deal breaker.