Detox: Detox tests hang on detox.init()

Describe the bug This is a bug that keeps showing up on Detox apparently but hasn’t been addressed recently. I am using react-native-firebase and specifically Crashlytics. It seems something is causing a crash when detox.init() is run. Specifically the test never gets past deviceDriver.waitUntilReady() in Device.js. I have been over the synchronization documentation but I don’t think it can help me as I cannot get to a point where the device global is exported.

To Reproduce

  • I have tested this issue on the latest Detox release and it still reproduces

Provide the steps necessary to reproduce the issue. If you are seeing a regression, try to provide the last known version where the issue did not reproduce.

  1. Create a react-native project and fully integrate react-native-firebase with Crashlytics.
  2. Setup detox following the Getting Started Guide using Jest
  3. Attempt to run a test in detox.
  4. Observe that the tests never run. The beforeAll does not complete in init.js and doesn’t export the globals.

If possible, please provide a small demo project that reproduces the issue, or attach a video with the reproduction - this would be very appreciated.

Expected behavior I expect the initialization to work regardless of other native dependencies.

Environment (please complete the following information):

  • Detox: ^12.1.4
  • React Native: 0.57.8
  • Node: v10.15.3
  • Device: iOS iPhone 7 Sim
  • Xcode: 10.2
  • iOS: 12.2
  • macOS: 10.14.3

Device and Verbose Detox Logs Provide the device and verbose Detox logs so we can understand what happened. You can obtain them by passing the loglevel param: detox test --loglevel verbose

detox test --debug-synchronization 12000 --loglevel verbose output:

detox[89116] WARN:  [test.js] Deprecation warning: "file" and "specs" support will be dropped in the next Detox version.
detox[89116] WARN:  [test.js] Please edit your package.json according to the migration guide: https://wix.to/I0DOAK0
detox[89116] INFO:  [test.js] configuration="ios.sim.debug" loglevel="verbose" debugSynchronization=12000 artifactsLocation="artifacts/ios.sim.debug.2019-04-15 20-09-51Z" recordLogs="none" takeScreenshots="none" recordVideos="none" node_modules/.bin/jest --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:android:).)*$' "e2e"
detox[89117] INFO:  [DetoxServer.js] server listening on localhost:61905...
detox[89117] DEBUG: [AsyncWebSocket.js/WEBSOCKET_OPEN] opened web socket to: ws://localhost:61905
detox[89117] DEBUG: [DetoxServer.js/LOGIN] role=tester, sessionId=956a2014-bdd8-fefa-47c1-b0a4f6e51395
detox[89117] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=tester, sessionId=956a2014-bdd8-fefa-47c1-b0a4f6e51395
detox[89117] DEBUG: [exec.js/EXEC_CMD, #0] /usr/bin/xcrun simctl list -j
detox[89117] DEBUG: [exec.js/EXEC_CMD, #1] applesimutils --list --byType "iPhone 7" --byOS "12.2"
detox[89117] DEBUG: [exec.js/EXEC_TRY, #1] Searching for device matching iPhone 7...
detox[89117] DEBUG: [exec.js/EXEC_CMD, #2] applesimutils --list --byId "5F44886B-82D9-40F7-8D12-1E6A0DF9963F"
detox[89117] DEBUG: [exec.js/EXEC_CMD, #3] /usr/bin/xcrun simctl uninstall 5F44886B-82D9-40F7-8D12-1E6A0DF9963F com.monarcbio.onevue
detox[89117] DEBUG: [exec.js/EXEC_TRY, #3] Uninstalling com.monarcbio.onevue...
detox[89117] DEBUG: [exec.js/EXEC_SUCCESS, #3] com.monarcbio.onevue uninstalled
detox[89117] DEBUG: [exec.js/EXEC_CMD, #4] /usr/bin/xcrun simctl install 5F44886B-82D9-40F7-8D12-1E6A0DF9963F "/Users/adamb/Developer/FSL/OneVue/ios/build/Build/Products/Debug-iphonesimulator/OneVue.app"
detox[89117] DEBUG: [exec.js/EXEC_TRY, #4] Installing /Users/adamb/Developer/FSL/OneVue/ios/build/Build/Products/Debug-iphonesimulator/OneVue.app...
detox[89117] DEBUG: [exec.js/EXEC_SUCCESS, #4] /Users/adamb/Developer/FSL/OneVue/ios/build/Build/Products/Debug-iphonesimulator/OneVue.app installed
detox[89117] DEBUG: [exec.js/EXEC_CMD, #5] /usr/bin/xcrun simctl terminate 5F44886B-82D9-40F7-8D12-1E6A0DF9963F com.monarcbio.onevue
detox[89117] DEBUG: [exec.js/EXEC_TRY, #5] Terminating com.monarcbio.onevue...
detox[89117] DEBUG: [exec.js/EXEC_SUCCESS, #5] com.monarcbio.onevue terminated
detox[89117] DEBUG: [exec.js/EXEC_CMD, #6] /bin/cat /dev/null >/Users/adamb/Library/Developer/CoreSimulator/Devices/5F44886B-82D9-40F7-8D12-1E6A0DF9963F/data/tmp/detox.last_launch_app_log.out 2>/Users/adamb/Library/Developer/CoreSimulator/Devices/5F44886B-82D9-40F7-8D12-1E6A0DF9963F/data/tmp/detox.last_launch_app_log.err && SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="/Users/adamb/Library/Detox/ios/11e6f51c3d7c5604b4955a94547a3726d9ab1ecd/Detox.framework/Detox" /usr/bin/xcrun simctl launch --stdout=/tmp/detox.last_launch_app_log.out --stderr=/tmp/detox.last_launch_app_log.err 5F44886B-82D9-40F7-8D12-1E6A0DF9963F com.monarcbio.onevue --args -detoxServer ws://localhost:61905 -detoxSessionId 956a2014-bdd8-fefa-47c1-b0a4f6e51395detox[89117] DEBUG: [exec.js/EXEC_TRY, #6] Launching com.monarcbio.onevue...
detox[89117] INFO:  [AppleSimUtils.js] com.monarcbio.onevue launched. The stdout and stderr logs were recreated, you can watch them with:
        tail -F /Users/adamb/Library/Developer/CoreSimulator/Devices/5F44886B-82D9-40F7-8D12-1E6A0DF9963F/data/tmp/detox.last_launch_app_log.{out,err
}
detox[89117] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=956a2014-bdd8-fefa-47c1-b0a4f6e51395)
detox[89117] DEBUG: [DetoxServer.js/LOGIN] role=testee, sessionId=956a2014-bdd8-fefa-47c1-b0a4f6e51395
detox[89117] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=testee, sessionId=956a2014-bdd8-fefa-47c1-b0a4f6e51395
 FAIL  e2e/firstTest.spec.js (120.841s)
  Example
    ✕ should skip onboarding (5ms)

  ● Example › should skip onboarding

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

      at mapper (../node_modules/jest-jasmine2/build/queue_runner.js:41:52)

  ● Example › should skip onboarding

    ReferenceError: device is not defined

      3 | describe('Example', () => {
      4 |   beforeEach(async () => {
    > 5 |     await device.reloadReactNative();
        |             ^
      6 |   });
      7 |
      8 |   test('should skip onboarding', async () => {

      at Object._callee$ (firstTest.spec.js:5:13)
      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._callee (firstTest.spec.js:4:79)

  ● Example › should skip onboarding

    ReferenceError: element is not defined

       7 |
       8 |   test('should skip onboarding', async () => {
    >  9 |     const skipBtn = element(by.id('onboardingFinish'));
         |             ^
      10 |     await expect(skipBtn).tap();
      11 |   });
      12 | });

      at Object._callee2$ (firstTest.spec.js:9:13)
      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:8:112)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        120.875s, estimated 121s
Ran all test suites matching /e2e/i with tests matching "^((?!:android:).)*$".
detox[89117] DEBUG: [DetoxServer.js/DISCONNECT] role=tester, sessionId=956a2014-bdd8-fefa-47c1-b0a4f6e51395
detox[89117] DEBUG: [DetoxServer.js/DISCONNECT] role=testee, sessionId=956a2014-bdd8-fefa-47c1-b0a4f6e51395
detox[89116] ERROR: [cli.js] Error: Command failed: node_modules/.bin/jest --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:android:).)*$' "e2e"

Device Log

2019-04-15 16:02:48.479 OneVue[89023:3409363] Crash handler setup started.
2019-04-15 16:02:48.479 OneVue[89023:3409363] Crash handler setup completed.
2019-04-15 16:02:48.479 OneVue[89023:3409363] Enabling accessibility for automation on Simulator.
2019-04-15 16:02:48.976 OneVue[89023:3409363] [Crashlytics] Version 3.10.9 (131)
2019-04-15 16:02:49.001 [info][tid:main][RCTCxxBridge.mm:216] Initializing <RCTCxxBridge: 0x600000f94ff0> (parent: <RCTBridge: 0x600001ba2530>, executor: (null))
2019-04-15 16:02:49.054 [info][tid:main][RCTRootView.m:293] Running application OneVue ({
    initialProps =     {
    };
    rootTag = 1;
})
2019-04-15 16:02:49.136 OneVue[89023:3409363] -[RNFirebase init] [Line 18] Setting up RNFirebase instance
2019-04-15 16:02:49.618 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/react-native-paper/src/components/FAB/FAB.js -> node_modules/react-native-paper/src/components/FAB/FABGroup.js -> node_modules/react-native-paper/src/components/FAB/FAB.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.627 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/react-native-paper/src/components/Appbar/Appbar.js -> node_modules/react-native-paper/src/components/Appbar/AppbarHeader.js -> node_modules/react-native-paper/src/components/Appbar/Appbar.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.630 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/react-native-paper/src/components/ToggleButton/ToggleButton.js -> node_modules/react-native-paper/src/components/ToggleButton/ToggleButtonGroup.js -> node_modules/react-native-paper/src/components/ToggleButton/ToggleButton.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.632 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/react-native-firebase/dist/utils/apps.js -> node_modules/react-native-firebase/dist/modules/core/app.js -> node_modules/react-native-firebase/dist/utils/apps.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.634 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/react-native-firebase/dist/modules/admob/index.js -> node_modules/react-native-firebase/dist/modules/admob/Interstitial.js -> node_modules/react-native-firebase/dist/modules/admob/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.635 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/react-native-firebase/dist/modules/admob/index.js -> node_modules/react-native-firebase/dist/modules/admob/RewardedVideo.js -> node_modules/react-native-firebase/dist/modules/admob/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.642 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/react-native-firebase/dist/modules/database/Reference.js -> node_modules/react-native-firebase/dist/utils/SyncTree.js -> node_modules/react-native-firebase/dist/modules/database/Reference.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.643 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/react-native-firebase/dist/modules/core/firebase.js ->node_modules/react-native-firebase/dist/utils/apps.js -> node_modules/react-native-firebase/dist/modules/core/app.js -> node_modules/react-native-firebase/dist/modules/database/index.js -> node_modules/react-native-firebase/dist/modules/core/firebase.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.645 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/react-native-firebase/dist/modules/firestore/DocumentSnapshot.js -> node_modules/react-native-firebase/dist/modules/firestore/DocumentReference.js -> node_modules/react-native-firebase/dist/modules/firestore/DocumentSnapshot.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.645 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/react-native-firebase/dist/modules/firestore/CollectionReference.js -> node_modules/react-native-firebase/dist/modules/firestore/Query.js -> node_modules/react-native-firebase/dist/modules/firestore/QuerySnapshot.js -> node_modules/react-native-firebase/dist/modules/firestore/DocumentChange.js -> node_modules/react-native-firebase/dist/modules/firestore/DocumentSnapshot.js -> node_modules/react-native-firebase/dist/modules/firestore/DocumentReference.js -> node_modules/react-native-firebase/dist/modules/firestore/CollectionReference.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.646 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/react-native-firebase/dist/modules/firestore/DocumentReference.js -> node_modules/react-native-firebase/dist/modules/firestore/utils/serialize.js -> node_modules/react-native-firebase/dist/modules/firestore/DocumentReference.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.647 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/react-native-firebase/dist/modules/firestore/utils/serialize.js -> node_modules/react-native-firebase/dist/modules/firestore/FieldValue.js -> node_modules/react-native-firebase/dist/modules/firestore/utils/serialize.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.649 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/react-native-firebase/dist/modules/core/firebase.js ->node_modules/react-native-firebase/dist/utils/apps.js -> node_modules/react-native-firebase/dist/modules/core/app.js -> node_modules/react-native-firebase/dist/modules/functions/index.js -> node_modules/react-native-firebase/dist/modules/core/firebase.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.657 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/react-native-firebase/dist/modules/storage/index.js ->node_modules/react-native-firebase/dist/modules/storage/reference.js -> node_modules/react-native-firebase/dist/modules/storage/task.js -> node_modules/react-native-firebase/dist/modules/storage/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.715 [warn][tid:com.facebook.react.JavaScript] Require cycle: src/App.jsx -> src/navigation/index.js -> src/navigation/auth.js ->src/screens/Login/index.jsx -> src/App.jsx

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.755 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/react-native-gesture-handler/index.js -> node_modules/react-native-gesture-handler/DrawerLayout.js -> node_modules/react-native-gesture-handler/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.879 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/Blob.js -> node_modules/rn-fetch-blob/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.880 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/XMLHttpRequest.js -> node_modules/rn-fetch-blob/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.881 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/FileReader.js -> node_modules/rn-fetch-blob/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.882 [warn][tid:com.facebook.react.JavaScript] Require cycle: node_modules/rn-fetch-blob/index.js -> node_modules/rn-fetch-blob/polyfill/index.js -> node_modules/rn-fetch-blob/polyfill/Fetch.js -> node_modules/rn-fetch-blob/index.js

Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
2019-04-15 16:02:49.955 [info][tid:com.facebook.react.JavaScript] Running application "OneVue" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
2019-04-15 16:02:50.053 [warn][tid:main][RCTView.m:712] (ADVICE) View #37 of type RCTView has a shadow set but cannot calculate shadow efficiently. Consider setting a background color to fix this, or apply the shadow to a more specific component.
2019-04-15 16:02:50.206 [info][tid:main][RNGestureHandlerManager.m:135] [GESTURE HANDLER] Initialize gesture handler for root view <RCTRootContentView: 0x7fa71ae21550; reactTag: 1; frame = (0 0; 375 667); gestureRecognizers = <NSArray: 0x600003ef14d0>; layer = <CALayer: 0x6000030e5560>>
2019-04-15 16:02:50.213 [warn][tid:main][RCTView.m:712] (ADVICE) View #177 of type RCTView has a shadow set but cannot calculate shadow efficiently.Consider setting a background color to fix this, or apply the shadow to a more specific component.
2019-04-15 16:02:50.216 [warn][tid:main][RCTView.m:712] (ADVICE) View #159 of type RCTView has a shadow set but cannot calculate shadow efficiently.Consider setting a background color to fix this, or apply the shadow to a more specific component.
2019-04-15 16:02:51.078 OneVue[89023:3409363] [Crashlytics:Crash] Warning: NSUncaughtExceptionHandler is 'grey_uncaughtExceptionHandler' in '/Users/adamb/Library/Detox/ios/11e6f51c3d7c5604b4955a94547a3726d9ab1ecd/Detox.framework/Frameworks/EarlGrey.framework/EarlGrey'
[Crashlytics] The signal SIGABRT has a non-Crashlytics handler ((null)).  This will interfere with reporting.
[Crashlytics] The signal SIGBUS has a non-Crashlytics handler ((null)).  This will interfere with reporting.
[Crashlytics] The signal SIGFPE has a non-Crashlytics handler ((null)).  This will interfere with reporting.
[Crashlytics] The signal SIGILL has a non-Crashlytics handler ((null)).  This will interfere with reporting.
[Crashlytics] The signal SIGSEGV has a non-Crashlytics handler ((null)).  This will interfere with reporting.
[Crashlytics] The signal SIGSYS has a non-Crashlytics handler ((null)).  This will interfere with reporting.
[Crashlytics] The signal SIGTRAP has a non-Crashlytics handler ((null)).  This will interfere with reporting.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 33 (15 by maintainers)

Most upvoted comments

If the app is idle (and you can interact with it, even if Detox appears stuck), means there is not a crash. Could be that Crashlytics has some kind of conflict with Detox. Could I ask you to try to reproduce this issue on a clean RN project (react-native init) and see if it reproduces there? If it does, please attach the project here. If it does not, the problem lies somewhere in your code.

Yes. It just warns you that the handler of uncaught exceptions (NSUncaughtExceptionHandler) is not their own. That’s not a crash.