Skip to content

Commit

Permalink
Merge pull request #3114 from cypress-io/warn-about-env
Browse files Browse the repository at this point in the history
docs: add notice about diff b/t Cypress.env and real env vars
  • Loading branch information
bencodezen authored Aug 31, 2020
2 parents 64c1ab5 + 3e0849f commit 9f9a657
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions source/_partial/cypress_env_var_warning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% note warning "Difference between OS-level and Cypress environment variables" %}
In Cypress, "environment variables" are variables that are accessible via `Cypress.env`. These are not the same as OS-level environment variables. However, [it is possible to set Cypress environment variables from OS-level environment variables](/guides/guides/environment-variables.html#Option-3-CYPRESS).
{% endnote %}
2 changes: 2 additions & 0 deletions source/api/cypress-api/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Environment variables set using `Cypress.env` _are only in scope for the current
Cypress runs each spec file in isolation: the browser is exited between specs. Environment variables added or changed in one spec won't be visible in other specs.
{% endnote %}

{% partial cypress_env_var_warning %}

# Syntax

```javascript
Expand Down
4 changes: 3 additions & 1 deletion source/guides/guides/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Environment Variables
---

{% partial cypress_env_var_warning %}

Environment variables are useful when:

- Values are different across developer machines.
Expand Down Expand Up @@ -123,7 +125,7 @@ Cypress.env('api_server') // 'http://localhost:8888/api/v1/'

## Option #3: `CYPRESS_*`

Any environment variable on your machine that starts with either `CYPRESS_` or `cypress_` will automatically be added and made available to you.
Any OS-level environment variable on your machine that starts with either `CYPRESS_` or `cypress_` will automatically be added to Cypress' environment variables and made available to you.

Conflicting values will override values from your configuration file (`cypress.json` by default) and `cypress.env.json` files.

Expand Down

0 comments on commit 9f9a657

Please sign in to comment.