DetoxRuntimeError: Detox instance has not been initialized

Detox on bitrise CI does not work but works locally. I’m using jest as my test runner. Here is the log that I always get:

detox[12731] INFO:  [test.js] configuration="ios.sim.release" cleanup=true debugSynchronization=200 reportSpecs=true DETOX_START_TIMESTAMP=1581386668122 node_modules/.bin/jest --config e2e/config.json '--testNamePattern=^((?!:android:).)*$' --maxWorkers 1 e2e/forgotPassword.spec.js
detox[12732] INFO:  [DetoxServer.js] server listening on localhost:51642...
detox[12732] INFO:  [AppleSimUtils.js] brdg.app launched. To watch simulator logs, run:
        /usr/bin/xcrun simctl spawn 68D1A658-61BF-424C-A633-DF6C3D6FEB0E log stream --level debug --style compact --predicate 'processImagePath beginsWith "/Users/vagrant/Library/Developer/CoreSimulator/Devices/68D1A658-61BF-424C-A633-DF6C3D6FEB0E/data/Containers/Bundle/Application/F300688C-7A7C-4C2D-AD0A-5FF5E8586E74/IntroPath.app"'
detox[12732] ERROR: [DetoxExportWrapper.js/DETOX_INIT_ERROR] 
 *** -[__NSDictionaryM setObject:forKey:]: key cannot be nil
(
	0   CoreFoundation                      0x00000001159456fb __exceptionPreprocess + 331
	1   libobjc.A.dylib                     0x0000000113e1eac5 objc_exception_throw + 48
	2   CoreFoundation                      0x0000000115893ddc _CFThrowFormattedException + 194
	3   CoreFoundation                      0x00000001159b49b4 -[__NSDictionaryM setObject:forKey:] + 1012
	4   IntroPath                           0x000000010f5cd5c8 -[RNMixpanel sharedInstanceWithToken:resolve:reject:] + 268
	5   CoreFoundation                      0x000000011594c4cc __invoking___ + 140
	6   CoreFoundation                      0x0000000115949a45 -[NSInvocation invoke] + 325
	7   CoreFoundation                      0x0000000115949e96 -[NSInvocation invokeWithTarget:] + 54
	8   IntroPath                           0x000000010f46170a -[RCTModuleMethod invokeWithBridge:module:arguments:] + 602
	9   IntroPath                           0x000000010f463b5d _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 251
	10  IntroPath                           0x000000010f4638df ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 78
	11  EarlGrey                            0x000000012f9fac72 __60-[GREYDispatchQueueTracker grey_dispatchAsyncCallWithBlock:]_block_invoke + 50
	12  libdispatch.dylib                   0x0000000116758ccf _dispatch_call_block_and_release + 12
	13  libdispatch.dylib                   0x0000000116759d02 _dispatch_client_callout + 8
	14  libdispatch.dylib                   0x0000000116760720 _dispatch_lane_serial_drain + 705
	15  libdispatch.dylib                   0x0000000116761261 _dispatch_lane_invoke + 398
	16  libdispatch.dylib                   0x0000000116769fcb _dispatch_workloop_worker_thread + 645
	17  libsystem_pthread.dylib             0x0000000116b3b611 _pthread_wqthread + 421
	18  libsystem_pthread.dylib             0x0000000116b3b3fd start_wqthread + 13
)
Forgot Password Screen: should verify that email field will check for a valid email format
Forgot Password Screen: should verify that email field will check for a valid email format [FAIL]
Forgot Password Screen: should verify that Reset Password button is disabled when email is blank or invalid format
Forgot Password Screen: should verify that Reset Password button is disabled when email is blank or invalid format [FAIL]
Forgot Password Screen: should verify that the email address entered is a valid Bridge account upon click of Reset Password. If not, display an error message
Forgot Password Screen: should verify that the email address entered is a valid Bridge account upon click of Reset Password. If not, display an error message [FAIL]
Forgot Password Screen: should verify that tapping Cancel will show the Create Account Screen
Forgot Password Screen: should verify that tapping Cancel will show the Create Account Screen [FAIL]
FAIL e2e/forgotPassword.spec.js (78.356s)
  Forgot Password Screen
    ✕ should verify that email field will check for a valid email format (10ms)
    ✕ should verify that Reset Password button is disabled when email is blank or invalid format (2ms)
    ✕ should verify that the email address entered is a valid Bridge account upon click of Reset Password. If not, display an error message (3ms)
    ✕ should verify that tapping Cancel will show the Create Account Screen (1ms)
  ● Forgot Password Screen › should verify that email field will check for a valid email format
    Failed: "*** -[__NSDictionaryM setObject:forKey:]: key cannot be nil
    (
    	0   CoreFoundation                      0x00000001159456fb __exceptionPreprocess + 331
    	1   libobjc.A.dylib                     0x0000000113e1eac5 objc_exception_throw + 48
    	2   CoreFoundation                      0x0000000115893ddc _CFThrowFormattedException + 194
    	3   CoreFoundation                      0x00000001159b49b4 -[__NSDictionaryM setObject:forKey:] + 1012
    	4   IntroPath                           0x000000010f5cd5c8 -[RNMixpanel sharedInstanceWithToken:resolve:reject:] + 268
    	5   CoreFoundation                      0x000000011594c4cc __invoking___ + 140
    	6   CoreFoundation                      0x0000000115949a45 -[NSInvocation invoke] + 325
    	7   CoreFoundation                      0x0000000115949e96 -[NSInvocation invokeWithTarget:] + 54
    	8   IntroPath                           0x000000010f46170a -[RCTModuleMethod invokeWithBridge:module:arguments:] + 602
    	9   IntroPath                           0x000000010f463b5d _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 251
    	10  IntroPath                           0x000000010f4638df ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 78
    	11  EarlGrey                            0x000000012f9fac72 __60-[GREYDispatchQueueTracker grey_dispatchAsyncCallWithBlock:]_block_invoke + 50
    	12  libdispatch.dylib                   0x0000000116758ccf _dispatch_call_block_and_release + 12
    	13  libdispatch.dylib                   0x0000000116759d02 _dispatch_client_callout + 8
    	14  libdispatch.dylib                   0x0000000116760720 _dispatch_lane_serial_drain + 705
    	15  libdispatch.dylib                   0x0000000116761261 _dispatch_lane_invoke + 398
    	16  libdispatch.dylib                   0x0000000116769fcb _dispatch_workloop_worker_thread + 645
    	17  libsystem_pthread.dylib             0x0000000116b3b611 _pthread_wqthread + 421
    	18  libsystem_pthread.dylib             0x0000000116b3b3fd start_wqthread + 13
    )"
      14 | jasmine.getEnv().addReporter(specReporter)
      15 | 
    > 16 | beforeAll(async () => {
         | ^
      17 |   await detox.init(config)
      18 | }, 300000)
      19 | 
      at Env.beforeAll (../node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:41:24)
      at Object.beforeAll (init.js:16:1)
          at Array.forEach (<anonymous>)
  ● Forgot Password Screen › should verify that email field will check for a valid email format
    DetoxRuntimeError: Detox instance has not been initialized
    HINT: There was an error on attempt to call detox.init()
       5 | describe('Forgot Password Screen', () => {
       6 |   beforeAll(async () => {
    >  7 |     await device.reloadReactNative()
         |           ^
       8 |   })
       9 | 
      10 |   it('should verify that email field will check for a valid email format', async () => {
      at MissingDetox.throwError (../node_modules/detox/src/utils/MissingDetox.js:67:11)
      at Object.get (../node_modules/detox/src/utils/MissingDetox.js:46:16)
      at device (forgotPassword.spec.js:7:11)
      at tryCatch (../node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (../node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.(anonymous function) [as next] (../node_modules/regenerator-runtime/runtime.js:97:21)
      at tryCatch (../node_modules/regenerator-runtime/runtime.js:45:40)
      at invoke (../node_modules/regenerator-runtime/runtime.js:135:20)
      at ../node_modules/regenerator-runtime/runtime.js:170:11
      at callInvokeWithMethodAndArg (../node_modules/regenerator-runtime/runtime.js:169:16)
      at AsyncIterator.enqueue (../node_modules/regenerator-runtime/runtime.js:192:13)
      at AsyncIterator.prototype.(anonymous function) [as next] (../node_modules/regenerator-runtime/runtime.js:97:21)
      at Object.<anonymous>.exports.async (../node_modules/regenerator-runtime/runtime.js:216:14)
      at Object._callee (forgotPassword.spec.js:6:13)

And here is the steps of the workflow:

e2e:
    steps:
    - activate-ssh-key@4.0.3:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - script@1.1.5:
        title: Git Configure
        inputs:
        - content: |
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            #Add know hosts
            ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts

            #Configure Git
            git config --global user.name $GITLAB_USER_NAME
            git config --global user.email $GITLAB_USER_EMAIL
    - git-clone: {}
    - yarn@0.0.8: {}
    - cocoapods-install@1.10.1:
        inputs:
        - podfile_path: "./ios/Podfile"
    - npm@1.1.1:
        inputs:
        - command: install -g detox-cli
        title: Install Detox CLI
    - install-react-native@0.9.2:
        inputs:
        - version: 2.0.1
    - script@1.1.6:
        inputs:
        - content: |-
            #!/bin/bash

            brew tap wix/brew
            brew install applesimutils --HEAD
        title: Install Detox Utils
    - script@1.1.6:
        inputs:
        - content: detox build --configuration ios.sim.release
        title: Detox - Build Debug App
    - npm@1.1.1:
        inputs:
        - command: rebuild detox
        title: Rebuild Detox
    - script@1.1.6:
        inputs:
        - is_debug: 'yes'
        - content: detox test --configuration ios.sim.release --debug-synchronization
            200 e2e/forgotPassword.spec.js --cleanup
        title: Detox - Run E2E Tests

Hope anyone can help, I tried many suggestions on the web but no luck.

Hi @archieherbias,

Thank you for reaching out.

Can you please provide a link to a full build log that reproduces this behaviour?

Thanks,
Luna

Hi @non-binary I am running into the same issue…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.