Detox React-Native 运行多个 e2e 文件
我开始在一个文件中使用 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\\.tsquot;,
"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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将此行添加到您的配置中:
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)