Detox React-Native 运行多个 e2e 文件

发布于 2025-01-13 06:14:38 字数 1828 浏览 4 评论 0原文

我开始在一个文件中使用 detox (在我的 React Native 项目中)进行多次测试,我想知道是否可以在多个文件中进行测试?

因为当我尝试使用 2 个不同的文件时,排毒从第 2 个文件开始,而不是从第 1 个文件开始?

这是我的 .detoxrc.json:

"testRunner": "jest",
  "runnerConfig": "e2e/config.json",
  "skipLegacyWorkersInjection": true,
  "apps": {
    "ios": {
      "type": "ios.app",
      "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/mobileApp.app",
      "build": "xcodebuild -workspace ios/mobileApp.xcworkspace -scheme mobileApp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build"
    },
    "android": {
      "type": "android.apk",
      "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
      "build": "cd android && ./gradlew app:assembleDebug app:assembleAndroidTest -DtestBuildType=debug && cd .."
    }
  },
  "devices": {
    "simulator": {
      "type": "ios.simulator",
      "device": {
        "type": "iPhone 11"
      }
    },
    "emulator": {
      "type": "android.emulator",
      "device": {
        "avdName": "Pixel_3a_API_28"
      }
    }

我的 config.json:

{
  "preset": "ts-jest",
  "testEnvironment": "node",
  "setupFilesAfterEnv": ["./init.ts"],
  "maxWorkers": 1,
  "testRunner": "jest-circus/runner",
  "testTimeout": 120000,
  "testRegex": "\\.e2e\\.ts$",
  "reporters": ["detox/runners/jest/streamlineReporter"],
  "verbose": true
}  

和我的 init.ts:

import { cleanup, init, device } from 'detox';

beforeAll(async () => {
  await init();
  await device.launchApp({ permissions: { photos: 'YES', camera: 'YES' } });
  await device.reloadReactNative();
});

beforeEach(async () => {
  await device.launchApp();
  // await device.reloadReactNative();
});

afterAll(async () => {
  await cleanup();
});

如果您有想法?

I started to do several test with detox (in my react native project) in one file and I was wondering if it was possible to do it in several files?

because when I tried in 2 different files, detox starts with the 2ND file and not the 1ST??

Here is my .detoxrc.json:

"testRunner": "jest",
  "runnerConfig": "e2e/config.json",
  "skipLegacyWorkersInjection": true,
  "apps": {
    "ios": {
      "type": "ios.app",
      "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/mobileApp.app",
      "build": "xcodebuild -workspace ios/mobileApp.xcworkspace -scheme mobileApp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build"
    },
    "android": {
      "type": "android.apk",
      "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
      "build": "cd android && ./gradlew app:assembleDebug app:assembleAndroidTest -DtestBuildType=debug && cd .."
    }
  },
  "devices": {
    "simulator": {
      "type": "ios.simulator",
      "device": {
        "type": "iPhone 11"
      }
    },
    "emulator": {
      "type": "android.emulator",
      "device": {
        "avdName": "Pixel_3a_API_28"
      }
    }

my config.json:

{
  "preset": "ts-jest",
  "testEnvironment": "node",
  "setupFilesAfterEnv": ["./init.ts"],
  "maxWorkers": 1,
  "testRunner": "jest-circus/runner",
  "testTimeout": 120000,
  "testRegex": "\\.e2e\\.ts
quot;,
  "reporters": ["detox/runners/jest/streamlineReporter"],
  "verbose": true
}  

and my init.ts:

import { cleanup, init, device } from 'detox';

beforeAll(async () => {
  await init();
  await device.launchApp({ permissions: { photos: 'YES', camera: 'YES' } });
  await device.reloadReactNative();
});

beforeEach(async () => {
  await device.launchApp();
  // await device.reloadReactNative();
});

afterAll(async () => {
  await cleanup();
});

If you have an idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

¢蛋碎的人ぎ生 2025-01-20 06:14:39

将此行添加到您的配置中:

setupFilesAfterEnv:['PATH_TO_INIT_FILE'](detox版本20)

或:

setupTestFrameworkScriptFile:'PATH_TO_INIT_FILE'(旧版本)

Add this line to your config:

setupFilesAfterEnv: ['PATH_TO_INIT_FILE'] (detox version 20)

or:

setupTestFrameworkScriptFile: 'PATH_TO_INIT_FILE' (old version)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文