---
title: Specify Environment Variables with Cypress Testing
description: How to specify which Test Environment variables with Cypress cross browser
  testing.
source_url:
  html: https://testingbot.com/support/web-automate/cypress/variables
  md: https://testingbot.com/support/web-automate/cypress/variables/index.md
---
# 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:

1. Using the `env` option key in your Cypress configuration file 
2. Create a `cypress.env.json` file and specify your environment variables 
3. Use the `--env` CLI flag with `testingbot-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](https://docs.cypress.io/guides/guides/environment-variables.html#Option-1-configuration-file).

    "env": {
        "signup_url": "/signup",
        "pricing_url": "/pricing"
    }

You can then access these values in Cypress with:

    Cypress.env() // {signup_url: '/signup', pricing_url: '/pricing'}
    Cypress.env('signup_url') // '/signup'
    Cypress.env('pricing_url') // '/pricing'

## 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 configuration file.   
 See the [Cypress env.json documentation](https://docs.cypress.io/guides/guides/environment-variables.html#Option-2-cypress-env-json).

    {
        "host": "testingbot.com",
        "api": "api.testingbot.com"
    }

You can then access these values in Cypress with:

    Cypress.env() // {host: 'testingbot.com', api: 'api.testingbot.com'}
    Cypress.env('host') // 'testingbot.com'
    Cypress.env('api') // 'api.testingbot.com'

## 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](https://docs.cypress.io/guides/guides/environment-variables.html#Option-4-env).

 Argument | Shorthand Argument | Possible values || `--env` | `-e` | comma-separated environment variables |

    testingbot-cypress run --env host=testingbot.com,api=api.testingbot.com

You can then access these values in Cypress with:

    Cypress.env() // {host: 'testingbot.com', api: 'api.testingbot.com'}
    Cypress.env('host') // 'testingbot.com'
    Cypress.env('api') // 'api.testingbot.com'

### Looking for more help?

Have questions or need more information? Reach out via email or Slack.

[Email us](https://testingbot.com/contact/new)[Slack Join our Slack](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
