【问题标题】:The simulator doesn't open when running detox test on iOS在 iOS 上运行 detox 测试时模拟器无法打开
【发布时间】:2020-11-04 08:56:33
【问题描述】:

当我尝试运行 detox test 时,模拟器似乎没有打开并且测试只是超时。

我确认我的设置是正确的,并尝试this 以确保我的模拟器可以从终端启动,并且我的detox 配置中的设备类型是正确的。

我收到的错误如下。

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.

DetoxRuntimeError: Detox instance has not been initialized

HINT: There was an error on attempt to call detox.init()

DetoxRuntimeError: Aborted detox.init() execution, and now running detox.cleanup()

HINT: Most likely, your test runner is tearing down the suite due to the timeout error

这是我的配置,出于隐私原因删除了应用名称。

"ios.sim.debug": {
    "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": {
        "type": "iPhone 11 Pro"
    }
},

如何调试?

【问题讨论】:

    标签: react-native react-native-ios detox


    【解决方案1】:

    我发现从 Xcode 9 detox 开始以无头模式运行 iOS 模拟器。如果您正在运行测试,然后使用 Spotlight 拉起模拟器并按 Enter 键,那么它将把 detox 已打开的所有模拟器带到前面。

    我是从这个comment 发现的。

    我还发现我的测试超时的原因是用户需要响应的提示阻止了detox 测试的进行。

    【讨论】:

      【解决方案2】:

      看起来您的测试中没有绑定 detox .init 方法。 确保你有 e2e/init.js 并且你需要添加

      before(async () => {
           await detox.init(config);
      });
      

      还要确保你在 config.json 中调用这个文件(这里可能是错误的,我在这里使用的是 Mocha 和 mocha.opts)

      【讨论】:

      • 感谢您的建议!我确实按照我的设置完全遵循了所有文档,e2e/init.jsconfig.json 等...对我来说,问题最终是 iOS 模拟器在无头模式下运行,所以它可以工作,但我没有看到所以我以为它坏了。
      • 很高兴你想通了
      猜你喜欢
      • 2020-08-24
      • 2014-07-24
      • 1970-01-01
      • 2020-08-22
      • 2020-12-10
      • 2018-03-16
      • 2014-03-23
      • 2022-09-28
      相关资源
      最近更新 更多