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

Set CYPRESS=true as env var in child processes where Cypress runs user code in Node #18805

Closed
jennifer-shehane opened this issue Nov 5, 2021 · 2 comments · Fixed by #18981
Closed
Assignees
Labels
type: feature New feature that does not currently exist

Comments

@jennifer-shehane
Copy link
Member

What would you like?

We'd like a way to tell that any Node code is running within Cypress. This way we could detect we're running in Cypress by looking for process.env.CYPRESS

Why is this needed?

Someone mentioned wanting the ability to set different babel config when run within Cypress specifically.

Other

No response

@jennifer-shehane jennifer-shehane added the type: feature New feature that does not currently exist label Nov 5, 2021
@cowboy
Copy link
Contributor

cowboy commented Nov 5, 2021

We need to create an example for public consumption that shows cypress component testing alongside jest testing, and we've found that the babel config actually needs to be slightly different in both scenarios.

We're looking for the best way to detect if the babel config is running inside cypress vs otherwise, and it's possible that jest sets an env var we can use for this conditional behavior, but it would be good if we had a cypress-specific way to test if a JS config file is running under cypress vs something else, so our solution could be portable to any scenario where cypress is running alongside some other testing framework.

Right now, we're doing this in our babel.config.js (which works), but we'd like a more "official" way:

if (process.env.CYPRESS_INTERNAL_ENV) {
  // do cypress-specific test things
} else {
  // do jest-specific test things
}

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 23, 2021

Released in 9.1.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v9.1.0, please open a new issue.

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Nov 23, 2021
@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Nov 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature New feature that does not currently exist
Projects
None yet
3 participants