cypress-documentation
                                
                                 cypress-documentation copied to clipboard
                                
                                    cypress-documentation copied to clipboard
                            
                            
                            
                        `CYPRESS_env` is a reserved environment variable name
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
- In your terminal: export CYPRESS_env=development
- In your cypress.config.js file:
    env: {
      barfoo: "from config",
      env: "local",
    },
- In a testing file, add
console.log('Env is ' + Cypress.env('env'))
- 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
- [X] PC
- [X] 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_ENVis 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_envaccepts 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.