【问题标题】:React Native Detox - Run specific test fileReact Native Detox - 运行特定的测试文件
【发布时间】:2021-01-07 08:41:39
【问题描述】:

我正在使用 Detox (https://github.com/wix/Detox) 运行 e2e 测试,我想知道是否有办法通过 CLI 或某些配置文件来控制要运行的测试文件。

目前我正在使用以下文件结构中的两个测试文件:

> e2e 
 config.json
 environment.js
 firstTest.js
 secondTest.js

我的 .detoxrc.json 文件如下:

{
 "testRunner": "jest",
 "runnerConfig": "e2e/config.json",
 "configurations": {
 "android.emu.debug": {
  "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
  "build":
    "cd android && sh gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
  "type": "android.emulator",
  "device": {
    "avdName": "Pixel_2_API_28"
  }
},
"android.emu.release": {
  "binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
  "build": "cd android && sh gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && 
   cd ..",
  "type": "android.emulator",
  "device": {
    "avdName": "Pixel_2_API_28"
  }
  }

 }
}

当我使用

运行测试时
detox test --configuration android.emu.debug

firstTest.js 先运行,然后 secondTest.js 运行,这很好。

有时您不想运行 firstTest.js 以节省时间,只运行 secondTest.js。

所以我的问题是:是否可以通过 detox CLI 或修改 .detoxrc.json 文件来控制运行哪个测试文件?还是通过其他方式?

我对注释掉 firstTest.js 文件中的所有测试或类似的东西不感兴趣。

【问题讨论】:

    标签: react-native detox


    【解决方案1】:

    您现在可以使用“-f 文件路径”标志从命令行执行此操作:

    detox test --configuration ios -f e2e/signupTest.e2e.js
    

    【讨论】:

    • 我试过这个,但它总是运行所有的测试文件。我正在使用“排毒”:“^17.4.4”。
    【解决方案2】:

    在 e2e 文件夹中你有 config.json 并且在配置里面你有 testRegex:

     "testRegex": "\\.js\\.js$"
    

    如果您只想运行一组/一组测试,您可以在此处更改名称并提供文件名。 示例:

    {
        "testEnvironment": "./environment",
        "testRunner": "jest-circus/runner",
        "testTimeout": 120000,
        "testRegex": "firstTest.js.js$",
        "reporters": ["detox/runners/jest/streamlineReporter"],
        "verbose": true
    

    }

    我明白你的感觉。在其他工具上,您可以添加标志。 这里有一些 cli 标志,但没有一个指向你想要的: https://github.com/wix/Detox/blob/master/docs/APIRef.DetoxCLI.md

    【讨论】:

      猜你喜欢
      • 2019-10-19
      • 2018-03-11
      • 2020-03-09
      • 2019-08-08
      • 2020-11-18
      • 2020-02-14
      • 2018-10-11
      • 2018-12-22
      • 2018-05-12
      相关资源
      最近更新 更多