[英]Pass env file to detox
我想在我的 react-native 應用程序中運行排毒測試時傳遞環境變量:
"ios.sim.debug": {
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/myapp.app",
"build": "export IS_DETOX=true && xcodebuild -workspace ios/myapp.xcworkspace -scheme my app -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"device": {
"type": "iPhone 11 Pro"
}
}
我已經安裝了react-native-config 。 但是當我運行排毒測試時,變量 IS_DETOX 在 JS 中是未定義的。
謝謝
我正在設置沒有export
環境變量。
我所有的 .env 變量都存儲在 config 文件夾中,我能夠為不同的配置加載不同的環境文件。
IOS
"ios.sim.release": {
"binaryPath": "ios/build/Build/Products/Release-iphonesimulator/Clim8Invest.app",
"build": "ENVFILE=config/.env.acceptance xcodebuild -workspace ios/Clim8Invest.xcworkspace -scheme Clim8Invest -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"device": {
"type": "iPhone 11"
}
},
安卓
"android.emu.debug.e2e": {
"binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
"build": "cd android && ENVFILE=../config/.env.e2e ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
"type": "android.emulator",
"device": {
"avdName": "Nexus_5X_A"
}
}
謝謝@黑!
在我這邊,我最終使用了來自Detox Mocking Guide 的RN_SRC_EXT=e2e.js
另一個解決方案,以便 detox 構建使用來自MyConfig.e2e.js
文件而不是MyConfig.js
文件的參數
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.