Cypress Test Environment Variables
You can easily setup test environment variables to be used with Cypress and TestingBot Cypress CLI.
There are currently three ways to do this:
-
Using the
env
option key in your Cypress configuration file -
Create a
cypress.env.json
file and specify your environment variables -
Use the
--env
CLI flag withtestingbot-cypress
Cypress Configuration File
Cypress allows you to specify your environment variables in the Cypress config file (cypress.json
or cypress.config.js
), under the env
option key.
You can learn more about this option in the Cypress Documentation.
You can then access these values in Cypress with:
cypress.env.json
You can also create your own cypress.env.json
file.
TestingBot's Cypress CLI will send this together with your specs to instruct Cypress to use these environment variables.
Values in this file will overwrite conflicting environment variables in your cypress.json
file.
See the Cypress env.json documentation.
You can then access these values in Cypress with:
CLI Flag
You can also pass a comma-separated list of environment variables with the TestingBot Cypress CLI. We will pass these values to the Cypress Runner.
Argument | Shorthand Argument | Possible values |
---|---|---|
--env |
-e |
comma-separated environment variables |
You can then access these values in Cypress with: