DetoxRuntimeError:Detox 实例尚未初始化

Posted

技术标签:

【中文标题】DetoxRuntimeError:Detox 实例尚未初始化【英文标题】:DetoxRuntimeError:Detox instance has not been initialized 【发布时间】:2020-06-17 16:28:59 【问题描述】:

问题描述:

当尝试为 Expo Ejected App 运行排毒测试时, detox build 成功,但是在尝试运行 detox test 时 面临以下错误

复制步骤:

    通过运行 npm install expo-cli -g 确保您拥有最新版本的 expo-cli 运行expo init创建一个新项目 cd 进入您的项目,使用 ExpoKit 选项运行 expo eject 运行yarn && cd ios && pod install 按照步骤配置排毒 运行expo服务器expo start -c 运行detox builddetox test

环境:

排毒:15.4.2 反应原生:0.59.10 节点:v8.11.0 设备:ios模拟器,任何型号 X代码:10.3 iOS:13.3

╰─ detox test -l trace -d --debug-synchronization
detox[90083] INFO:  [test.js] configuration="ios.sim.Debug" loglevel="trace" debugSynchronization=3000 reportSpecs=true DETOX_START_TIMESTAMP=1583325845491 node_modules/.bin/jest --config e2e/config.json '--testNamePattern=^((?!:android:).)*$' --maxWorkers 1 "e2e"
detox[90084] TRACE: [Detox.js/DETOX_CREATE] created a Detox instance with config:
"deviceConfig":"binaryPath":"ios/build/Build/Products/Debug-iphonesimulator/example.app","build":"xcodebuild -workspace ios/example.xcworkspace -scheme example -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build","type":"ios.simulator","device":"iPhone 11 Pro","artifactsConfig":"rootDir":"artifacts/ios.sim.Debug.2020-03-04 12-44-05Z","plugins":"log":"enabled":false,"keepOnlyFailedTestsArtifacts":false,"screenshot":"enabled":true,"shouldTakeAutomaticSnapshots":false,"keepOnlyFailedTestsArtifacts":false,"video":"enabled":false,"keepOnlyFailedTestsArtifacts":false,"instruments":"enabled":false,"keepOnlyFailedTestsArtifacts":false,"timeline":"enabled":false,"pathBuilder":"_rootDir":"artifacts/ios.sim.Debug.2020-03-04 12-44-05Z"
detox[90084] INFO:  [DetoxServer.js] server listening on localhost:61975...
detox[90084] DEBUG: [AsyncWebSocket.js/WEBSOCKET_OPEN] opened web socket to: ws://localhost:61975
detox[90084] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] "type":"login","params":"sessionId":"e6cf1f34-7237-a519-6ccc-2b7996db8f0b","role":"tester","messageId":0
detox[90084] DEBUG: [DetoxServer.js/LOGIN] role=tester, sessionId=e6cf1f34-7237-a519-6ccc-2b7996db8f0b
detox[90084] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=tester, sessionId=e6cf1f34-7237-a519-6ccc-2b7996db8f0b
detox[90084] TRACE: [AsyncWebSocket.js/WEBSOCKET_MESSAGE] "type":"loginSuccess","params":"sessionId":"e6cf1f34-7237-a519-6ccc-2b7996db8f0b","role":"tester","messageId":0

detox[90084] DEBUG: [exec.js/EXEC_CMD, #0] applesimutils --list --byType "iPhone 11 Pro"
detox[90084] TRACE: [exec.js/EXEC_SUCCESS, #0] [
  
    "deviceType" : 
      "name" : "iPhone 11 Pro",
      "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 11 Pro.simdevicetype",
      "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-11-Pro"
    ,
    "state" : "Booted",
    "isAvailable" : true,
    "name" : "iPhone 11 Pro",
    "udid" : "9FD7C5EA-F3B7-4E26-A79E-0A848ADE1269",
    "os" : 
      "buildversion" : "17C45",
      "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime",
      "isAvailable" : true,
      "name" : "iOS 13.3",
      "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-13-3",
      "version" : "13.3"
    
  
]

detox[90084] DEBUG: [exec.js/EXEC_CMD, #1] applesimutils --list --byId 9FD7C5EA-F3B7-4E26-A79E-0A848ADE1269 --maxResults 1
detox[90084] TRACE: [exec.js/EXEC_SUCCESS, #1] [
  
    "deviceType" : 
      "name" : "iPhone 11 Pro",
      "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/DeviceTypes\/iPhone 11 Pro.simdevicetype",
      "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-11-Pro"
    ,
    "state" : "Booted",
    "isAvailable" : true,
    "name" : "iPhone 11 Pro",
    "udid" : "9FD7C5EA-F3B7-4E26-A79E-0A848ADE1269",
    "os" : 
      "buildversion" : "17C45",
      "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime",
      "isAvailable" : true,
      "name" : "iOS 13.3",
      "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-13-3",
      "version" : "13.3"
    
  
]

detox[90084] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBootDevice( coldBoot: false,
  deviceId: '9FD7C5EA-F3B7-4E26-A79E-0A848ADE1269',
  type: 'iPhone 11 Pro' )
detox[90084] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBeforeUninstallApp( deviceId: '9FD7C5EA-F3B7-4E26-A79E-0A848ADE1269',
  bundleId: 'org.reactjs.native.example.example' )
detox[90084] DEBUG: [exec.js/EXEC_CMD, #2] /usr/bin/xcrun simctl uninstall 9FD7C5EA-F3B7-4E26-A79E-0A848ADE1269 org.reactjs.native.example.example
detox[90084] DEBUG: [exec.js/EXEC_TRY, #2] Uninstalling org.reactjs.native.example.example...
detox[90084] TRACE: [exec.js/EXEC_SUCCESS, #2]
detox[90084] DEBUG: [exec.js/EXEC_SUCCESS, #2] org.reactjs.native.example.example uninstalled
detox[90084] DEBUG: [exec.js/EXEC_CMD, #3] /usr/bin/xcrun simctl install 9FD7C5EA-F3B7-4E26-A79E-0A848ADE1269 "/Users/vayu/testReactNative/testExpo/example/ios/build/Build/Products/Debug-iphonesimulator/example.app"
detox[90084] DEBUG: [exec.js/EXEC_TRY, #3] Installing /Users/vayu/testReactNative/testExpo/example/ios/build/Build/Products/Debug-iphonesimulator/example.app...
detox[90084] TRACE: [exec.js/EXEC_SUCCESS, #3]
detox[90084] DEBUG: [exec.js/EXEC_SUCCESS, #3] /Users/vayu/testReactNative/testExpo/example/ios/build/Build/Products/Debug-iphonesimulator/example.app installed
detox[90084] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBeforeTerminateApp( deviceId: '9FD7C5EA-F3B7-4E26-A79E-0A848ADE1269',
  bundleId: 'org.reactjs.native.example.example' )
detox[90084] DEBUG: [exec.js/EXEC_CMD, #4] /usr/bin/xcrun simctl terminate 9FD7C5EA-F3B7-4E26-A79E-0A848ADE1269 org.reactjs.native.example.example
detox[90084] DEBUG: [exec.js/EXEC_TRY, #4] Terminating org.reactjs.native.example.example...
detox[90084] TRACE: [exec.js/EXEC_SUCCESS, #4]
detox[90084] DEBUG: [exec.js/EXEC_SUCCESS, #4] org.reactjs.native.example.example terminated
detox[90084] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onTerminateApp( deviceId: '9FD7C5EA-F3B7-4E26-A79E-0A848ADE1269',
  bundleId: 'org.reactjs.native.example.example' )
detox[90084] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBeforeLaunchApp( bundleId: 'org.reactjs.native.example.example',
  deviceId: '9FD7C5EA-F3B7-4E26-A79E-0A848ADE1269',
  launchArgs:
    detoxServer: 'ws://localhost:61975',
     detoxSessionId: 'e6cf1f34-7237-a519-6ccc-2b7996db8f0b'  )
detox[90084] DEBUG: [exec.js/EXEC_CMD, #5] SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="/Users/vayu/Library/Detox/ios/48f56fb4523932cb5da30a7799afef21908baa16/Detox.framework/Detox" /usr/bin/xcrun simctl launch 9FD7C5EA-F3B7-4E26-A79E-0A848ADE1269 org.reactjs.native.example.example --args -detoxServer "ws://localhost:61975" -detoxSessionId "e6cf1f34-7237-a519-6ccc-2b7996db8f0b"
detox[90084] DEBUG: [exec.js/EXEC_TRY, #5] Launching org.reactjs.native.example.example...
detox[90084] TRACE: [exec.js/EXEC_SUCCESS, #5] org.reactjs.native.example.example: 90123

detox[90084] DEBUG: [exec.js/EXEC_CMD, #6] /usr/bin/xcrun simctl get_app_container 9FD7C5EA-F3B7-4E26-A79E-0A848ADE1269 org.reactjs.native.example.example
detox[90084] TRACE: [exec.js/EXEC_SUCCESS, #6] /Users/vayu/Library/Developer/CoreSimulator/Devices/9FD7C5EA-F3B7-4E26-A79E-0A848ADE1269/data/Containers/Bundle/Application/8641A39F-B558-4183-96C4-0F6C587827DF/example.app

detox[90084] INFO:  [AppleSimUtils.js] org.reactjs.native.example.example launched. To watch simulator logs, run:
        /usr/bin/xcrun simctl spawn 9FD7C5EA-F3B7-4E26-A79E-0A848ADE1269 log stream --level debug --style compact --predicate 'process == example'
detox[90123] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onLaunchApp( bundleId: 'org.reactjs.native.example.example',
  deviceId: '9FD7C5EA-F3B7-4E26-A79E-0A848ADE1269',
  launchArgs:
    detoxServer: 'ws://localhost:61975',
     detoxSessionId: 'e6cf1f34-7237-a519-6ccc-2b7996db8f0b' ,
  pid: 90123 )
detox[90084] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] "type":"isReady","params":,"messageId":-1000
detox[90084] TRACE: [DetoxServer.js/MESSAGE] role=tester action=isReady (sessionId=e6cf1f34-7237-a519-6ccc-2b7996db8f0b)
detox[90084] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=e6cf1f34-7237-a519-6ccc-2b7996db8f0b)
detox[90084] DEBUG: [DetoxServer.js/LOGIN] role=testee, sessionId=e6cf1f34-7237-a519-6ccc-2b7996db8f0b
detox[90084] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=testee, sessionId=e6cf1f34-7237-a519-6ccc-2b7996db8f0b
Example: should have welcome screen
Example: should have welcome screen [FAIL]
Example: should show hello screen after tap
Example: should show hello screen after tap [FAIL]
Example: should show world screen after tap
Example: should show world screen after tap [FAIL]

 FAIL  e2e/firstTest.spec.js (300.742s)
  Example
    ✕ should have welcome screen (6ms)
    ✕ should show hello screen after tap (2ms)
    ✕ should show world screen after tap (1ms)

  ● Example › should have welcome screen

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

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

  ● Example › should have welcome screen

    DetoxRuntimeError: Detox instance has not been initialized

    HINT: Make sure to call detox.init() before your test begins

      at MissingDetox.throwError (../node_modules/detox/src/utils/MissingDetox.js:67:11)
      at MissingDetox._defineRequiredProperty (../node_modules/detox/src/utils/MissingDetox.js:8:71)
      at DetoxExportWrapper.(anonymous function).args [as beforeEach] (../node_modules/detox/src/DetoxExportWrapper.js:53:32)
      at DetoxAdapterImpl.beforeEach (../node_modules/detox/runners/jest/DetoxAdapterImpl.js:17:22)

  ● Example › should have welcome screen

    DetoxRuntimeError: Detox instance has not been initialized

    HINT: Make sure to call detox.init() before your test begins

      1 | describe('Example', () => 
      2 |   beforeEach(async () => 
    > 3 |     await device.reloadReactNative();
        |           ^
      4 |   );
      5 |
      6 |   it('should have welcome screen', async () => 

      at MissingDetox.throwError (../node_modules/detox/src/utils/MissingDetox.js:67:11)
      at device (../node_modules/detox/src/utils/MissingDetox.js:46:16)
      at _callee$ (firstTest.spec.js:3: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 (firstTest.spec.js:2:14)

  ● Example › should have welcome screen

    DetoxRuntimeError: Detox instance has not been initialized

    HINT: Make sure to call detox.init() before your test begins

       5 |
       6 |   it('should have welcome screen', async () => 
    >  7 |     await expect(element(by.id('welcome'))).toBeVisible();
         |                          ^
       8 |   );
       9 |
      10 |   it('should show hello screen after tap', async () => 

      at MissingDetox.throwError (../node_modules/detox/src/utils/MissingDetox.js:67:11)
      at by (../node_modules/detox/src/utils/MissingDetox.js:46:16)
      at _callee2$ (firstTest.spec.js:7:26)
      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._callee2 (firstTest.spec.js:6:36)

  ● Example › should show hello screen after tap

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

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

  ● Example › should show hello screen after tap

    DetoxRuntimeError: Detox instance has not been initialized

    HINT: Make sure to call detox.init() before your test begins

      at MissingDetox.throwError (../node_modules/detox/src/utils/MissingDetox.js:67:11)
      at MissingDetox._defineRequiredProperty (../node_modules/detox/src/utils/MissingDetox.js:8:71)
      at DetoxExportWrapper.(anonymous function).args [as beforeEach] (../node_modules/detox/src/DetoxExportWrapper.js:53:32)
      at DetoxAdapterImpl.beforeEach (../node_modules/detox/runners/jest/DetoxAdapterImpl.js:17:22)

  ● Example › should show hello screen after tap

    DetoxRuntimeError: Detox instance has not been initialized

    HINT: Make sure to call detox.init() before your test begins

      1 | describe('Example', () => 
      2 |   beforeEach(async () => 
    > 3 |     await device.reloadReactNative();
        |           ^
      4 |   );
      5 |
      6 |   it('should have welcome screen', async () => 

      at MissingDetox.throwError (../node_modules/detox/src/utils/MissingDetox.js:67:11)
      at device (../node_modules/detox/src/utils/MissingDetox.js:46:16)
      at _callee$ (firstTest.spec.js:3: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 (firstTest.spec.js:2:14)

  ● Example › should show hello screen after tap

    DetoxRuntimeError: Detox instance has not been initialized

    HINT: Make sure to call detox.init() before your test begins

       9 |
      10 |   it('should show hello screen after tap', async () => 
    > 11 |     await element(by.id('hello_button')).tap();
         |                   ^
      12 |     await expect(element(by.text('Hello!!!'))).toBeVisible();
      13 |   );
      14 |

      at MissingDetox.throwError (../node_modules/detox/src/utils/MissingDetox.js:67:11)
      at by (../node_modules/detox/src/utils/MissingDetox.js:46:16)
      at _callee3$ (firstTest.spec.js:11:19)
      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._callee3 (firstTest.spec.js:10:44)

  ● Example › should show world screen after tap

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

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

  ● Example › should show world screen after tap

    DetoxRuntimeError: Detox instance has not been initialized

    HINT: Make sure to call detox.init() before your test begins

      at MissingDetox.throwError (../node_modules/detox/src/utils/MissingDetox.js:67:11)
      at MissingDetox._defineRequiredProperty (../node_modules/detox/src/utils/MissingDetox.js:8:71)
      at DetoxExportWrapper.(anonymous function).args [as beforeEach] (../node_modules/detox/src/DetoxExportWrapper.js:53:32)
      at DetoxAdapterImpl.beforeEach (../node_modules/detox/runners/jest/DetoxAdapterImpl.js:17:22)

  ● Example › should show world screen after tap

    DetoxRuntimeError: Detox instance has not been initialized

    HINT: Make sure to call detox.init() before your test begins

      1 | describe('Example', () => 
      2 |   beforeEach(async () => 
    > 3 |     await device.reloadReactNative();
        |           ^
      4 |   );
      5 |
      6 |   it('should have welcome screen', async () => 

      at MissingDetox.throwError (../node_modules/detox/src/utils/MissingDetox.js:67:11)
      at device (../node_modules/detox/src/utils/MissingDetox.js:46:16)
      at _callee$ (firstTest.spec.js:3: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 (firstTest.spec.js:2:14)

  ● Example › should show world screen after tap

    DetoxRuntimeError: Detox instance has not been initialized

    HINT: Make sure to call detox.init() before your test begins

      14 |
      15 |   it('should show world screen after tap', async () => 
    > 16 |     await element(by.id('world_button')).tap();
         |                   ^
      17 |     await expect(element(by.text('World!!!'))).toBeVisible();
      18 |   );
      19 | );

      at MissingDetox.throwError (../node_modules/detox/src/utils/MissingDetox.js:67:11)
      at by (../node_modules/detox/src/utils/MissingDetox.js:46:16)
      at _callee4$ (firstTest.spec.js:16:19)
      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._callee4 (firstTest.spec.js:15:44)

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

我的 Init.js

const config = require('../package.json').detox;
const adapter = require('detox/runners/jest/adapter');
const specReporter = require('detox/runners/jest/specReporter');

// Set the default timeout
jest.setTimeout(120000);

jasmine.getEnv().addReporter(adapter);

// This takes care of generating status logs on a per-spec basis. By default, jest only reports at file-level.
// This is strictly optional.
jasmine.getEnv().addReporter(specReporter);

beforeAll(async () => 
  await detox.init(config);
, 300000);

beforeEach(async () => 
  await adapter.beforeEach();
);

afterAll(async () => 
  await adapter.afterAll();
  await detox.cleanup();
):

【问题讨论】:

【参考方案1】:

注意:我使用“mocha”作为跑步者并使用版本排毒:“^15.4.2”,mocha:“^7.1.0”

出现此错误,对我而言,原因是我试图在 it() 函数之外通过控制台注销元素的文本以进行比较。

it('should have Text: A', async () => 
      await expect(element(by.text('A'))).toBeVisible();
);
 >>>> console.log('ELE:: DATE::', element(by.id('TID-datefilter')));
it('should have Text: B', async () => 
      await expect(element(by.text('B'))).toBeVisible();
);

删除后效果很好。

【讨论】:

但是@Aron Edwards,我的所有语句都在 it() 块中,而且代码在 detox 初始化过程中被阻塞,没有找到 detox 实例让代码继续前进跨度> 您的init.js 似乎是排毒脚手架提供的那个。我有相同的,但在我的代码中使用 Jest 并且没有 console 语句!但我仍然得到Async - Callback was not invoked...

以上是关于DetoxRuntimeError:Detox 实例尚未初始化的主要内容,如果未能解决你的问题,请参考以下文章

实模式

数字信号处理傅里叶变换性质 ( 序列傅里叶变换共轭对称性质 | 序列实偶 傅里叶变换 实偶 | 序列实奇 傅里叶变换 虚奇 | 证明 “ 序列实奇 傅里叶变换 虚奇 “ )

网页设计实训心得三篇

网页设计实训总结心得6篇(2)

模板与泛型编程——模板实参推断

实训心得