Overview

Environments in Supatest allow you to manage different configurations for your test suites. 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

[Screenshot: Environment selection dropdown in the sidebar showing ‘No Environment’ and other available environments]

Creating an Environment

  1. Navigate to the Environments tab
  2. Click the ’+ Create Environment’ button
  3. Enter a name for your environment
  4. Click ‘Create’

A confirmation toast will appear when your environment is created successfully.

[Screenshot: Create Environment form with the name field and create button]

Managing Environment Variables

Adding Variables

  1. Select an environment from the environments tab
  2. Click ’+ Add Variable’
  3. 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

[Screenshot: Add Variable form showing the name, type dropdown, and value fields]

Best Practices

  1. Naming Convention

    • Use UPPERCASE with underscores
    • Be descriptive and consistent
    • Examples: API_BASE_URL, AUTH_TOKEN, ADMIN_PASSWORD
  2. 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:

  1. When creating or editing a test case, type {{ to trigger the environment variables dropdown
  2. Select the desired variable from the list
  3. The variable will be inserted in the format {{VARIABLE_NAME}}

[Screenshot: Environment variables dropdown triggered by typing {{ in a test case]

For example:

{{BASE_URL}}/api/users

Note: If you don’t see your variable in the dropdown, ensure:

  • 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

Video Tutorial

Watch our video tutorial to see the Environments feature in action:

[Video: Step-by-step guide on creating environments, managing variables, and using them in test cases]

Key timestamps:

  • 0:00 - Introduction to Environments
  • 0:30 - Creating your first environment
  • 1:15 - Adding and managing variables
  • 2:00 - Using variables in test cases
  • 3:00 - Best practices and tips