Overview
Environments in Supatest allow you to manage different configurations for your test folders and individual test cases. This feature is particularly useful when you need to test your application across multiple environments (e.g., development, staging, production) or with different configuration values. By default, Supatest starts with ‘No Environment’ selected. You can:- Create multiple environments
- Configure environment-specific variables
- Switch between environments using the dropdown in the sidebar
- Use environment variables in your test cases
Creating an Environment
- Navigate to the Environments tab
- Click the ’+ Create Environment’ button
- Enter a name for your environment
- Click ‘Create’
Managing Environment Variables
Adding Variables
- Select an environment from the environments tab
- Click ’+ Add Variable’
- Fill in the variable details:
- Name: The variable identifier (e.g.,
API_BASE_URL
) - Type: Choose from:
- String
- Number
- Boolean
- Secret (for sensitive data)
- Value: The value for your variable
- Name: The variable identifier (e.g.,
Best Practices
-
Naming Convention
- Use UPPERCASE with underscores
- Be descriptive and consistent
- Examples:
API_BASE_URL
,AUTH_TOKEN
,ADMIN_PASSWORD
-
Variable Management
- Each variable name must be unique within an environment
- You can reuse variable names across different environments
- Use secrets for sensitive information like passwords and API keys
Using Environment Variables in Test Cases
To use environment variables in your test cases:- When creating or editing a test case, type
{{
to trigger the environment variables dropdown - Select the desired variable from the list
- The variable will be inserted in the format
{{VARIABLE_NAME}}
{{
in a test case]
For example:
- The correct environment is selected in the sidebar
- The variable exists in the selected environment
Tips for Multiple Environments
- Create separate environments for different stages (dev, staging, prod)
- Keep variable names consistent across environments
- Only change the values to match each environment’s requirements
- This approach allows you to run the same test cases across different environments without modifying the test logic