expo / config-plugins

Out-of-tree Expo config plugins for packages that haven't adopted the config plugin system yet.
445 stars 95 forks source link

[detox] build command (generate .app file) with .env variables #17

Closed vlimag closed 3 years ago

vlimag commented 3 years ago

Hello.

We are trying to set a e2e test suite, but struggling to get the environment variables working (when testing).

Currently, we have a managed expo project (ios/android folders being created with expo run:'platform') with some environment variables being set on app.config.js (from .env file).

When we build locally using expo run:ios, for example, the variables work just fine. The issue is when we generate the build for being used on the e2e tests.

In this case, app.config.js has undefined variables.

The command we are using for generating the .app file is this one: xcodebuild -workspace ios/detoxexpoblank.xcworkspace -scheme detoxexpoblank -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build | npx excpretty ./

We are looking for a way to attach the environment variables on the generated build.

We tried adding require('dotenv').config() on the test files, but that doesn't work either.

Any help would be really appreciated.

Thanks

EvanBacon commented 3 years ago

Possibly related: https://github.com/expo/expo-cli/issues/2782

vlimag commented 3 years ago

We solved by adding babel-plugin-dotenv-import on the project. And all the .env vars added from this. none from app.config.js anymore.

Thanks