e2e tests not reading .local.env file.
See original GitHub issueCurrent Behaviour
When I run a react app with @nrwl/web:dev-server
, .local.env is loaded, as described here: https://nx.dev/angular/cli/overview#loading-environment-variables
When I run the e2e tests created by the react plugin, the variables are undefined.
Expected Behavior
The e2e version of the front end app should have the variables available.
Steps to Reproduce
Setup an app similar to the react tutorial.
Add a .local.env, with some values that begin with NX_
. Console.log those values on app start.
Failure Logs
No failure logs
Environment
➜ yarn nx --version
yarn run v1.22.4
$ nx --version
9.4.5
➜ node --version
v13.14.0
➜ cat /etc/lsb-release
DISTRIB_ID=Pop
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Pop!_OS 20.04 LTS"
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
How to read environment files from e2e tests? - Stack Overflow
I'm using Cypress for the e2e tests. For instance, I want to use the base URL, so that it depends on the environment...
Read more >Environment Variables | Cypress Documentation
In Cypress, "environment variables" are variables that are accessible via Cypress.env . These are not the same as OS-level environment variables.
Read more >How to create dynamic E2E testing environments | by Shai Tubul
Configuring and deploying an environment. We defined YAML files that describe the E2E test environments, so each YAML file describes one environment as...
Read more >Cypress v10 Environment Variables - Gleb Bahmutov
We see only the environment variables from the e2e block. ... we can access the process environment variables, or read local files, etc....
Read more >Run your Cypress suites across environments reusing the ...
Now, for you to execute your e2e tests across environments there would ... in the .env files. eg below is the .env file...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Update 30/12/20
We’ve now determined that Cypress will load environment variables in the correct order, and NOT overwrite them in subsequent
.env
files, but ONLY if both environment variable files are placed in the appropriate app folder. In other words, if you have.local.env
and.env
in the root of your project, you’re going to have problems. If you place those files inside the app that you’re running e2e against, it works as expected.We would love some clarification on whether this is intentional or not - it still doesn’t seem to be the expected behavior.
@Cammisuli @jaysoo we should probably add the same feature to the cypress builder.