Documentation
Test Execution

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.

Availability: API testing is available on all plans. Add 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.

1
Define the Request

Set the URL, HTTP method (GET, POST, PUT, DELETE), headers, and request body.

2
Add Assertions

Assert on status code, response body (with JSON path matching), and response time.

3
Run & Review

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:

FieldDescriptionExample
ActionStep typeapi-request
SelectorThe API endpoint URLhttps://api.example.com/users
ValueHTTP methodGET, POST, PUT, DELETE

Request Configuration (via Assertions)

Configure headers, body, and assertions in the step's assertions field:

PropertyTypeDescription
headersObjectRequest headers (e.g., {"Authorization": "Bearer token123"})
bodyString/ObjectRequest body for POST/PUT requests
timeoutNumberRequest timeout in milliseconds (default: 30000)
expectedStatusNumberExpected HTTP status code (e.g., 200)
expectedBodyObjectJSON path assertions on response body
maxResponseTimeNumberMaximum 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
Tip: API steps skip screenshot capture since there's no browser page involved. This makes them faster and more lightweight than UI steps.

Combining UI and API Tests

One of AegisRunner's strengths is combining UI and API tests in a single suite. Common patterns:

PatternDescription
API Setup → UI TestCreate test data via API, then verify it appears in the UI
UI Action → API VerifySubmit a form in the UI, then verify the API response
API Health CheckVerify API endpoints are healthy before running UI tests
Performance GateCheck 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

API Testing Tips:
  • Use test variables ({{variableName}}) for authentication tokens and dynamic data
  • Set reasonable maxResponseTime thresholds 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

Need help?

Can't find what you're looking for? Our support team is here to help.