【问题标题】:How to have Detox test run only on IOS & disable Android run如何仅在 IOS 上运行 Detox 测试并禁用 Android 运行
【发布时间】:2019-05-17 20:35:14
【问题描述】:

我正在使用 Detox 为 iOS 创建一些 UI 测试。 最初,iOS 测试运行良好。 [注意-目前没有任何 Android 测试]

Config.json
{
    "setupTestFrameworkScriptFile": "./init.js",
    "testEnvironment": "node"
}

package.json sn-p:

"detox": {
"configurations": {
  "ios.sim.debug": {
    "binaryPath": "/Users/laxmisomni/Documents/Projects/mambo/ios/build/Build/Products/Debug-iphonesimulator/mambo.app",
    "build": "xcodebuild -workspace ios/appName.xcworkspace -scheme appName -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
    "type": "ios.simulator",
    "name": "iPhone 7"
  }
},
"test-runner": "jest",
"specs": "e2e"
},

错误:

Ran all test suites matching /e2e/i with tests matching "^((?!:android:).)*$".
child_process.js:651
    throw err;
    ^

Error: Command failed: node_modules/.bin/jest e2e --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:android:).)*$'
    at checkExecSyncError (child_process.js:611:11)

Other dependencies in Package.json:
    "babel-eslint": "^8.2.3",
    "babel-jest": "23.0.1",
    "babel-preset-react-native": "4.0.0",
    "babel-register": "^6.26.0",

有什么方法可以禁用尝试运行不存在的 Android 测试的测试运行器?

【问题讨论】:

    标签: react-native detox


    【解决方案1】:

    Detox 没有运行安卓测试。由于正则表达式中的negative lookahead,它看起来只是这样。

    --testNamePattern='^((?!:android:).)*$'

    这是我运行的成功 iOS 测试的输出。

    detox test
    node_modules/.bin/jest e2e --config=e2e/config.json --maxWorkers=1 --testNamePattern='^((?!:android:).)*$'
    
     server listening on localhost:55356...
    
     : Searching for device matching iPhone 7...
    
     : Uninstalling com.testapp.test...
    
     : com.testapp.test uninstalled
     : Installing /Users/work/Documents/test/ios/build/Build/Products/Debug-iphonesimulator/test.app...
     : /Users/work/Documents/test/ios/build/Build/Products/Debug-iphonesimulator/test.app installed
     : Terminating  com.testapp.test...
     : com.testapp.test terminated
     : Launching  com.testapp.test...
    7: com.testapp.test launched. The stdout and stderr logs were recreated, you can watch them with:
            tail -F /Users/work/Library/Developer/CoreSimulator/Devices/AF406169-5CF3-4480-9D00-8F934C420043/data/tmp/detox.last_launch_app_log.{out,err}
     PASS  e2e/firstTest.spec.js (10.504s)
      Example
        ✓ should have Home tab (1283ms)
        ✓ should show detail screen after tap (1872ms)
    
    Test Suites: 1 passed, 1 total
    Tests:       2 passed, 2 total
    Snapshots:   0 total
    Time:        11.153s, estimated 12s
    Ran all test suites matching /e2e/i with tests matching "^((?!:android:).)*$".
    

    关于您的测试失败,如果没有看到日志的完整输出,我们无法为您提供帮助。

    【讨论】:

      猜你喜欢
      • 2020-08-24
      • 2020-01-03
      • 2018-05-21
      • 2018-12-22
      • 2020-10-23
      • 2020-11-04
      • 2016-03-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多