【问题标题】:Unable to run test case using detox无法使用 detox 运行测试用例
【发布时间】:2019-06-24 21:43:36
【问题描述】:

我在使用 detox 运行测试用例时遇到以下错误。 我已经安装了所有依赖项。

Can't find a simulator to match with " iPhone 6 ", run 'xcrun simctl list' to list your supported devices.

configuration="ios.sim.debug" artifactsLocation="artifacts/ios.sim.debug.2019-01-31 12-14-41Z" node_modules/.bin/jest "e2e" --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:android:).)*$' 
detox[5864] INFO:  [DetoxServer.js] server listening on localhost:57598...
detox[5864] ERROR: [index.js/DETOX_INIT_ERROR] 
 Error: Can't find a simulator to match with " iPhone 6 ", run 'xcrun simctl list' to list your supported devices.
      It is advised to only state a device type, and not to state iOS version, e.g. "iPhone 7"
    at AppleSimUtils.findDevicesUDID (/Users/alok/Desktop/malliswari/accordion/node_modules/detox/src/devices/ios/AppleSimUtils.js:46:13)
    at process._tickCallback (internal/process/next_tick.js:68:7)

【问题讨论】:

  • 您不应该将错误发布为图像,您应该复制并粘贴错误消息。请复制并粘贴整个错误消息。

标签: react-native detox


【解决方案1】:

这是由于将 package.json 中的 detox 配置中的模拟器设置为系统上不存在的模拟器所致

"detox": {
    "configurations": {
      "ios.sim.debug": {
        "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/myapp.app",
        "build": "RN_SRC_EXT=e2e.js xcodebuild -workspace ios/myapp.xcworkspace -scheme myapp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
        "type": "ios.simulator",
        "name": "iPhone 7" // <- this is where you define your simulator
      }
    },

您应该在终端中运行 xcrun simctl list 以查看可用的模拟器。然后使用detox 配置中可用的一种。您应该可以将其更改为 "iPhone 7""iPhone 8"

【讨论】:

  • 我使用 iPhone X 作为模拟器并根据它更新了 package.json。
  • }, "detox": { "configurations": { "ios.sim.debug": { "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/detoxtest.app" , "build": "xcodebuild -project ios/detoxtest.xcodeproj -scheme detoxtest -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build", "type": "ios.simulator", "name": "iPhone X" } } , "test-runner": "jest" } }
  • 面临以下错误 .Detox[28802] 错误: [exec.js/EXEC_FAIL, #6] /bin/sh: /Users/alok/Library/Developer/CoreSimulator/Devices/3C26850F-B9D1- 48D2-9491-224F76C0E69A/data/tmp/detox.last_launch_app_log.out:没有这样的文件或目录
  • 删除ios/build文件夹并使用detox build -c ios.sim.debug &amp;&amp; detox test -c ios.sim.debug'进行排毒重建
  • 说真的,如果您继续在 cmets 中发布错误,我将无能为力,您需要将其发布在问题中,并且它必须是全部
【解决方案2】:

这里有另一种可能的解决方案

https://github.com/wix/Detox/issues/1103

我们需要升级 AppleSimUtils。如果您在升级时遇到问题check out here

【讨论】:

    猜你喜欢
    • 2018-10-24
    • 1970-01-01
    • 2015-08-14
    • 1970-01-01
    • 2019-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多