Environment Variables

Manage configuration and secrets

Overview

Environment variables let you manage configuration and secrets outside your test files. Create a .zelte.env file in your project root.

Creating Environment Files

Create a .zelte.env file with your variables:

.zelte.env
API_BASE_URL=http://localhost:3000
API_TOKEN=your-secret-token
API_USERNAME=testuser
API_PASSWORD=testpass
.zelte.env.example
# Copy this file to .zelte.env and fill in your values
API_BASE_URL=http://localhost:3000
API_TOKEN=your-secret-token
API_USERNAME=testuser
API_PASSWORD=testpass

Using Variables in Tests

Reference environment variables in your collection:

collection.yaml
variables:
  baseUrl: ${API_BASE_URL}
  token: ${API_TOKEN}

tests:
  - id: login
    request:
      url: ${baseUrl}/auth/login
      headers:
        Authorization: Bearer ${token}
    assertions:
      - status == 200

Multiple Environments

Use different environment files for different stages:

Terminal
# Development
zelte run collection.yaml --env development

# Staging  
zelte run collection.yaml --env staging

# Production
zelte run collection.yaml --env production