React Native Detox-运行特定的测试文件

问题描述

我正在使用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 ..","device": {
    "avdName": "Pixel_2_API_28"
  }
  }

 }
}

当我使用进行测试时

detox test --configuration android.emu.debug

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

有时您不希望运行firstTest.js来节省时间,而只运行secondTest.js。

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

我对虚拟黑客不感兴趣,例如注释掉firstTest.js文件中的所有测试或类似的东西。

解决方法

在e2e文件夹中,您具有config.json,在配置内部,您具有testRegex:

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

如果您只想运行1组测试文件,则可以在那里更改名称并指定文件名。 示例:

{
    "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

,

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

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

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...