How does Cypress.io read the Windows environment variables?
From cypress documentation here:
Any environment variable on your machine that starts with either CYPRESS_
or cypress_
will automatically be added and made available to you.
Conflicting values will override values from cypress.json
and cypress.env.json
files.
Cypress will strip off the CYPRESS_
when adding your environment variables.
Exporting cypress env variables from the command line:
export CYPRESS_HOST=laura.dev.local
export cypress_api_server=http://localhost:8888/api/v1/
If you're using Windows you can set env variables using set
or setx
commands.
And in your test files you can call this:
Cypress.env() // {HOST: "laura.dev.local", api_server: "http://localhost:8888/api/v1"}
Cypress.env("HOST") // "laura.dev.local"
Cypress.env("api_server") // "http://localhost:8888/api/v1/"