Overview
Assertions validate that your API responses match expected conditions. Zelte supports a wide range of assertion types for comprehensive testing.
Status Code Assertions
Check HTTP response status codes:
collection.yaml
assertions:
- status == 200
- status != 404
- status >= 200 && status < 300
- status == 201Body Assertions
Validate response body content:
collection.yaml
assertions:
# Equality checks
- body.id == 123
- body.name == "John Doe"
- body.active == true
# Null checks
- body.token !== null
- body.error === undefined
# String operations
- body.message contains "success"
- body.email contains "@"
# Array checks
- body.users.length > 0
- Array.isArray(body.items)Header Assertions
Validate response headers:
collection.yaml
assertions:
- headers.content-type == "application/json"
- headers.authorization exists
- headers.x-rate-limit-remaining > 0Response Time Assertions
Ensure your API meets performance requirements:
collection.yaml
assertions:
- responseTime < 1000 # Under 1 second
- responseTime > 100 # At least 100ms
- responseTime < 5000 # Under 5 seconds