Environments
Environments let you define variables for different contexts like development, staging, and production. Switch between them without changing your tests.
Creating an Environment File
Create a .nornenv file with your environments:
# Common variables (always available)
var timeout = 30000
var apiVersion = v1
[env:dev]
var baseUrl = http://localhost:3000
var apiKey = dev-key-12345
[env:staging]
var baseUrl = https://staging.api.example.com
var apiKey = staging-key-67890
[env:prod]
var baseUrl = https://api.example.com
secret apiKey = prod-key-secret Importing Shared Environment Files
Split shared settings into separate .nornenv files and import them at the top of your main environment file. Import paths are relative to the file that declares them.
var timeout = 30000
[env:dev]
var baseUrl = http://localhost:3000
[env:staging]
var baseUrl = https://staging.api.example.com import "./shared/base/.nornenv"
var apiVersion = v1
[env:dev]
var paymentsPath = /payments
[env:staging]
var paymentsPath = /payments Then use the merged variables in your tests:
GET {{baseUrl}}{{paymentsPath}}/health
X-API-Version: {{apiVersion}} Keep import statements at the top of the file. Imports can chain through other .nornenv files, but duplicate variable names in the same scope are treated as configuration errors.
Using Environment Variables
Reference variables in your .norn files:
GET {{baseUrl}}/users
Authorization: Bearer {{apiKey}} {{name}} keeps the normal lookup order. If a file variable, local variable, or sequence parameter shadows an environment variable, use {{$env.name}} to read the active environment value explicitly.
var baseUrl = https://example.local
print "local={{baseUrl}} env={{$env.baseUrl}}"
GET {{$env.baseUrl}}/users Switching Environments
Use the Command Palette (Cmd+Shift+P) and select:
Norn: Select Environment Or click the environment name in the status bar.
Secret Variables
Mark sensitive variables as secrets to prevent them from appearing in logs:
[env:prod]
var baseUrl = https://api.example.com
secret apiKey = prod-key-secret
secret password = ENC[NORN_AGE_V1:kid=team-main:abc123xyz] Secret values are automatically redacted in:
- Response panel output
- CLI logs
- Test reports
Environment in CLI
Specify the environment when running tests:
norn tests/ --env staging Default Values
Variables defined outside any section are available in all environments:
# Available in all environments
var timeout = 30000
[env:dev]
var baseUrl = http://localhost:3000
[env:staging]
var baseUrl = https://staging.example.com Nested Values
Use JSON for complex values:
[env:dev]
var testUser = {"id": 1, "name": "Test User"} Access nested properties:
GET {{baseUrl}}/users/{{testUser.id}}