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

CYPRESS_env is a reserved environment variable name #5847

Open
2 of 6 tasks
gilzow opened this issue Jun 21, 2024 · 0 comments
Open
2 of 6 tasks

CYPRESS_env is a reserved environment variable name #5847

gilzow opened this issue Jun 21, 2024 · 0 comments

Comments

@gilzow
Copy link
Contributor

gilzow commented Jun 21, 2024

Description

When I export CYPRESS_env, I expect that value to override the env:env value set in the config file, but nothing happened instead.

URL of Issue(s)

https://docs.cypress.io/guides/guides/environment-variables

Steps to replicate

  1. In your terminal: export CYPRESS_env=development
  2. In your cypress.config.js file:
    env: {
      barfoo: "from config",
      env: "local",
    },
  1. In a testing file, add
console.log('Env is ' + Cypress.env('env'))
  1. Run the test

Output will be

Env is local

Where I would expect it to be

Env is development

Browser

Chrome 125.0.6422.113

Device

  • PC
  • Mac
  • iPhone
  • iPad
  • Android Phone
  • Android Tablet

Additional Information

Given the documentation on Environment Variable states:

Environment variables that match a corresponding configuration option will override any value set in the Cypress configuration.

And the note above that section states:

The environment variable CYPRESS_INTERNAL_ENV is reserved and should not be set.

I was surprised when I was unable to get CYPRESS_env to override the env:env value I had set in the cypress.config.js file (specifically so I can set some intercepts when testing locally vs testing in our development instance). I initially thought it was a bug with Cypress (and submitted an issue) but according to @jennifer-shehane :

CYPRESS_env accepts an object as its argument, to override the entire env object. [emphasis mine]

This behavior needs to be documented possibly with a note alongside the one for CYPRESS_INTERNAL_ENV.

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

No branches or pull requests

1 participant