Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.env and dotnev does not pass variables into Cypress.env #807

Open
macmladen opened this issue Nov 16, 2022 · 0 comments
Open

.env and dotnev does not pass variables into Cypress.env #807

macmladen opened this issue Nov 16, 2022 · 0 comments

Comments

@macmladen
Copy link

In the current version of the cypress-example-recipes/examples/server-communication__env-variables/.env , in the comment

# these variables will be read automatically
# CYPRESS_ part will be removed
# access them with Cypress.env("ping"), Cypress.env("HOST")
CYPRESS_ping=123
CYPRESS_HOST=laura.dev.local
cypress_api_server=http://localhost:8888/api/v1/

It suggests that variables will be read and they do appear as test asserts pass.

But it is passing due to the command-line argument, not the .env file.

"cypress:open": "../../node_modules/.bin/cross-env FOO=42 BAR=baz CYPRESS_ping=123 CYPRESS_HOST=laura.dev.local cypress_api_server=http://localhost:8888/api/v1/ ../../node_modules/.bin/cypress open",

dotenv correctly includes the content of the .env into the process.env object, however, while cypress does have CYPRESS_ variables submitted in the command line, it seems that the addition of the dotenv comes too late and Cypress already passed over environment variables.

If that is the case then that comment and sample variables should be deleted as they are misleading.

Tested with: Cypress 11.1, macOS 11.13.6, node 16.15.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant