Skip to main content
No Result Found
Connect and get help from 7,000+ developers on our Discord community. Ask the CommunityAsk the Community

Environment variables

Use environment variables in BrowserStack Load Testing to parameterize tests and avoid hard-coding secrets. You can also mask sensitive values to prevent exposure in the browser console or CLI logs.

You can set environment variables to pass dynamic values to your load tests, such as API keys, user credentials, or configuration settings.

Mask sensitive values

Mark environment variables as masked to hide their values across the BrowserStack Load Testing dashboard. Use this for API keys, passwords, tokens, and other credentials you don’t want surfaced when reviewing or sharing a load test.

Masked values are hidden:

  • When configuring a load test
  • On load test details and run history pages
  • When comparing runs
  • In links you share with others

Masked values are not hidden:

  • Inside your test runtime - your script reads process.env.X as the original value. This is required for tests to actually run.
  • In logs your test prints to stdout - anything your script writes (console.log, framework debug output) appears verbatim in your run logs. If your test logs a secret, mask it in your test code as well.
  • In your local .env source file, BrowserStack never modifies the file you upload. Masking is opt-in per variable. Both UI Builder and CLI support it - see each tab below for the exact steps.

Configure environment variables

First, set up your environment variables using either the UI Builder or CLI. Once configured, you can enable masking for sensitive values.

Depending on your preferred method, select any one of the following:

Configure environment variables

Use environment variables to avoid hard-coding secrets and to parameterize your test runs:

  • Upload one or more .env files (up to 5 MB each) by dragging and dropping into the upload area:
    • You can upload .env, .yaml, .yml, .json, .properties, .ini, or .cfg files.
    • After upload, the variables become available to your test run.
  • Manually add key–value pairs:
    • Click Add Variable, then enter the Key and Value.
    • Your variables are saved for this run and applied during execution.
    • Use the bin icon to delete any key-value pair

Screenshot of load testing dashboard asking to upload env variable files and add values

Enable masking in UI Builder

To mask a variable when using the UI Builder:

  1. Select the closed-eye icon next to the variable name you want to mask.
  2. The variable value is then hidden wherever sensitive values should not be exposed.

Where masked values are not exposed:

  • UI Builder editor
  • Public-facing interfaces

Where masked values remain visible:

  • Test execution on BrowserStack (for debugging purposes)

Configure environment variables

The env config lets you pass an array of name-value string pairs to set environment variables on the remote machines where tests are executed.
Currently, a maximum of 20 pairs is allowed (masked and non-masked variables count together toward this limit).

Environment variables can be set using any one of the following two methods:

Inline variables

Declare each variable with a name and value. BrowserStack injects these pairs into the test environment.

File-based variables

Use sources to reference one or more files containing environment variables (for example, .env files). Use variables to add or override specific pairs.
Result: the system loads values from files first, then applies overrides.

browserstack-load.yml
env:
  sources:
   - path/to/env/file
  variables:
   - name: "variable1"
     value: "value1"
   - name: "variable2"
     value: "value2"

Enable masking in CLI

To mask a variable in your YAML configuration, set isMasked: true for that variable:

Where masked values are not exposed:

  • Public-facing test runner interfaces

Where masked values remain visible:

  • BrowserStack web console (for debugging)
  • Test execution environment (required for tests to run)

Masking requires a BrowserStack Load Testing CLI version that supports the isMasked parameter. To check your CLI version, run browserstack-load-testing --version. If your CLI does not support isMasked, upgrade to the latest version before you use this parameter.

Example
env:
  variables:
   - name: "API_KEY"
     value: "sk-prod-abc123xyz"
     isMasked: true
   - name: "PUBLIC_URL"
     value: "https://api.example.com"

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle