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

Closed
Zidious opened this issue Jul 4, 2024 · 4 comments
Closed

envs are not being propagated as expected #29807

Zidious opened this issue Jul 4, 2024 · 4 comments
Labels
existing workaround stage: needs investigating Someone from Cypress needs to look at this stale no activity on this issue for a long period type: unexpected behavior User expected result, but got another

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 🐦

@jennifer-shehane jennifer-shehane added type: unexpected behavior User expected result, but got another stage: needs investigating Someone from Cypress needs to look at this existing workaround labels Jul 29, 2024
@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Jan 26, 2025
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
existing workaround stage: needs investigating Someone from Cypress needs to look at this stale no activity on this issue for a long period type: unexpected behavior User expected result, but got another
Projects
None yet
Development

No branches or pull requests

4 participants