In mabl, you can define variables at the environment level and use them across multiple tests. Environment variables are great for defining environment-specific URLs, API endpoints, and API keys so that you can run the same tests across multiple environments such as staging and production.
In the mabl app, you can create and review environment variables from the environments page: Configuration > Environments. This article explains how to add environment variables.
You can also manage environment variables programmatically from the mabl CLI and mabl API. These options are great for making updates in bulk.
Add environment variables
You can add environment variables from the environments page in the mabl app: Configuration > Environment. Open the environment you want to edit, and click on the pencil icon in the top left corner to edit the environment.
The environment details page
Add environment variables manually
If you need to add a small number of environment variables, click on the + Add environment variable button to add them manually. If you are using a variable across different environments, make sure that the name matches exactly. Variable names are case sensitive.
Use all caps for environment variable names
By using the conventional "screaming snake case," you can quickly distinguish environment variables from the other variables in a test. Examples: "API_URL", "ADMIN_USERNAME"
Import environment variables from Postman
To import a pre-existing Postman environment into mabl, click the Import Postman variables button and upload the JSON of your Postman environment. Choose which variables to import, including editing their names and values. When you save the Import Postman variables form, the variables are added to the environment.
Importing Postman environment variables
A warning icon indicates a conflict with an existing variable in the environment. Saving the conflicting variable overwrites the existing value in your environment.
Limitations
When you save environment variables, they are serialized to JSON and encrypted using an encryption key specific to your workspace. The total size of serialized environment variables for a given environment cannot exceed 64kb.
Environment variables cannot contain references to another variable, such as {{@another_variable}}.