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

envs are not being propagated as expected #29807

Open
Zidious opened this issue Jul 4, 2024 · 2 comments
Open

envs are not being propagated as expected #29807

Zidious opened this issue Jul 4, 2024 · 2 comments

Comments

@Zidious
Copy link

Zidious commented Jul 4, 2024

Current behavior

Given that you can supply env via defineConfig via the top level env property, the e2e env property and setupNodeEvents(_, config env property, these appear to not be all propagating to Cypress.env(..)

Desired behavior

Expect all forms of providing envs via defineConfig to be propagated to Cypress.env(..)

Test code to reproduce

Given this example:

module.exports = defineConfig({
  env: { AA: 'AA' },
  e2e: {
    env: { BB: 'BB' },
    setupNodeEvents(_, config) {
      config.env.CC = 'CC'
      return config
    }
  }
})

Placeholder test:

describe('describe', () => {
  it('it', () => {
    cy.visit('https://google.com')
  })
})

Only BB and CC envs are propagated:

image

Cypress Version

13.13.0

Node version

18.19

Operating System

macOS Sonoma 14.5

Debug Logs

No response

Other

No response

@Zidious
Copy link
Author

Zidious commented Jul 10, 2024

Hey team! Any update on this at all?

@D0d0d
Copy link

D0d0d commented Jul 14, 2024

Setting your e2e.env as e2e:{env:{...}} simply overwrites top-level env.

As I see, this way we can use top-level env like default, and switch it to another if we need it for another testing type. I couldnt find it in docs, but I believe it is normal case.

If you want to keep your top-level env, but have many fields to add and find dict-view prettier, you can still use something like this:

  e2e: {
    setupNodeEvents(_, config) {
      config.env = Object.assign({}, config.env, { 
        BB: 'Bb' 
      }),

Just my point of view anyway 🐦

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

2 participants