Skip to main content

Introduction

Environment variables provide a centralized way to store values that can be shared across all tests in your project. They are managed through the Test Data section in your workspace.
Environment variables live at the project level and are shared by every test in the workspace. For test-specific values, use local variables instead.
JSON values are supported and accessible in your tests as JSON objects.

Adding Environment Variables

1

Navigate to Test Data

Go to Test Data → Variables in your workspace.
2

Add variable

Click + Add Variable to create a new environment variable.
3

Set the scope

Select the environment for which this variable will be accessible.
Environment-level variables will be accessible to all tests. Use these to store API keys, base URLs, and common configuration values.
4

Configure its value

Enter the variable name and value. JSON values are supported and accessible in your tests as JSON objects.
5

Set the sensitivity

Toggle Sensitive to encrypt and hide the value after creation.
You will not be able to see or change the values of sensitive variables after creation.
6

Save the variable

Save the variable to make it available across all of your tests.

Using Environment Variables

All variables (both environment and local) are accessed through the same VARS object in your tests.

In Custom Code

Use VARS.<name> to reference any variable:
// Access environment variables
const apiKey = VARS.apiKey;
const baseUrl = VARS.baseUrl;

// Use in your test logic
await page.goto(`${VARS.baseUrl}/login`);

In Input Fields

When filling out text inputs, you can reference variables directly:
Fill value dialog

In AI Instructions

Variables are automatically available to Stably’s AI, so you can use them in prompts:
  • “Navigate to VARS.baseUrl
  • “Fill in the username with VARS.testUsername

Best Practices

✔️ Do❌ Avoid
Store secrets and API keys as Sensitive variables.Hard-coding credentials directly in tests.
Use descriptive, lower-camelCase names (apiKeyProduction).Abbreviations that will be hard to remember (akp).
Create environment-specific variables for different staging environments.Using the same credentials across all environments.
Use environment variables for values shared across multiple tests.Creating duplicate variables with the same value.
See also: Variables for information about local variables and other variable types.