DetoxRuntimeError:排毒实例尚未初始化

时间:2020-03-05 05:17:10

标签: ios testing expo detox

问题描述:

当尝试为Expo Exjected App运行排毒测试时, detox build成功,但是在尝试运行detox test时 面对

的以下错误

DetoxRuntimeError:Detox实例尚未初始化

复制步骤:

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

环境:

排毒:15.4.2 React Native:0.59.10 节点:v8.11.0 设备:ios模拟器,任何型号 Xcode: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 个答案:

答案 0 :(得分:0)

注意:我将'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();
});

删除后效果很好。