API Testing
Test REST and GraphQL API endpoints alongside your UI tests. Configure method, URL, headers, body, and assertions from the visual step editor — no code required.
API Testing
AegisRunner lets you test REST and GraphQL API endpoints directly as test steps alongside your UI tests. No separate tooling needed — define API requests, run them, and assert on the results.
api-request steps to any test suite.
How It Works
API test steps use Node.js fetch directly — no browser page needed. This means API tests are fast, lightweight, and can be mixed into the same suite as UI tests.
Set the URL, HTTP method (GET, POST, PUT, DELETE), headers, and request body.
Assert on status code, response body (with JSON path matching), and response time.
Execute the test. View the full request/response details, timing, and assertion results.
Creating an API Test Step
When editing a test case, add a step with the api-request action:
| Field | Description | Example |
|---|---|---|
| Action | Step type | api-request |
| Selector | The API endpoint URL | https://api.example.com/users |
| Value | HTTP method | GET, POST, PUT, DELETE |
Request Configuration (via Assertions)
Configure headers, body, and assertions in the step's assertions field:
| Property | Type | Description |
|---|---|---|
headers | Object | Request headers (e.g., {"Authorization": "Bearer token123"}) |
body | String/Object | Request body for POST/PUT requests |
timeout | Number | Request timeout in milliseconds (default: 30000) |
expectedStatus | Number | Expected HTTP status code (e.g., 200) |
expectedBody | Object | JSON path assertions on response body |
maxResponseTime | Number | Maximum response time in milliseconds |
Examples
GET Request with Status Assertion
{
"action": "api-request",
"selector": "https://api.example.com/health",
"value": "GET",
"assertions": {
"expectedStatus": 200
}
}
POST Request with Body Assertions
{
"action": "api-request",
"selector": "https://api.example.com/users",
"value": "POST",
"assertions": {
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer {{apiToken}}"
},
"body": {
"name": "Test User",
"email": "test@example.com"
},
"expectedStatus": 201,
"expectedBody": {
"id": "string",
"name": "Test User"
},
"maxResponseTime": 2000
}
}
GET Request with JSON Path Matching
{
"action": "api-request",
"selector": "https://api.example.com/products/123",
"value": "GET",
"assertions": {
"expectedStatus": 200,
"expectedBody": {
"data.product.name": "Widget",
"data.product.price": 29.99,
"data.product.inStock": true
}
}
}
JSON path matching uses dot notation to navigate nested objects. For example, data.product.name checks response.data.product.name.
Viewing API Test Results
After running tests with API steps, the step results display:
- Method & URL — The HTTP method and endpoint tested
- Status Code — Color-coded (green for 2xx, red for 4xx/5xx)
- Response Time — How long the request took in milliseconds
- Response Body — Collapsible formatted JSON body
- Request Details — Headers and body that were sent
Combining UI and API Tests
One of AegisRunner's strengths is combining UI and API tests in a single suite. Common patterns:
| Pattern | Description |
|---|---|
| API Setup → UI Test | Create test data via API, then verify it appears in the UI |
| UI Action → API Verify | Submit a form in the UI, then verify the API response |
| API Health Check | Verify API endpoints are healthy before running UI tests |
| Performance Gate | Check API response times meet SLAs |
AI-Generated API Tests
When your crawl data includes API endpoints (e.g., from form submissions or AJAX requests), the AI test generator can automatically create API test steps with appropriate assertions.
Best Practices
- Use test variables (
{{variableName}}) for authentication tokens and dynamic data - Set reasonable
maxResponseTimethresholds for performance monitoring - Test both success and error scenarios (200, 400, 401, 404, 500)
- Use JSON path assertions for specific fields rather than matching entire response bodies
- Combine API health checks with UI tests for comprehensive coverage
- Keep API test steps at the beginning of suites to fail fast on backend issues
Related Documentation
- Running Tests - Execute test suites
- Visual Regression Testing - Pixel-level screenshot comparisons
- AI Test Generation - Auto-generate tests from crawl data
- Test Data Management - Configure test variables and data