Docs

Testing Scenarios

API Testing Examples

Use these common scenarios to test how your applications handle different API behaviors without changing your backend code.

API Downtime Simulation

Test how your app handles service unavailability

Response Latency

Test loading states with delayed responses

GraphQL Extension

Add new fields to GraphQL responses

Custom Error Scenarios

Test specific API error conditions

API Downtime Simulation

Test how your app handles service unavailability

Configuration

mockql.config.js
{
  "scenario": "downtime",
  "target": {
    "url": "/api/users",
    "method": "GET"
  },
  "response": {
    "status": 503,
    "headers": {
      "Retry-After": "30"
    },
    "body": {
      "error": "Service Unavailable",
      "message": "The service is temporarily unavailable",
      "retryAfter": 30
    }
  }
}

How It Works

This configuration returns a 503 error for the users endpoint, allowing you to test how your application handles API outages.

Works with your existing API without code changes

Tests error handling and retry mechanisms

Configurable via simple JSON or JavaScript

Tips for API Testing

Error Handling

Test both expected errors (400, 403) and unexpected errors (500, 503) to ensure your app remains functional.

Performance

Simulate slow responses to verify loading states and ensure your UI remains responsive during API delays.

Data Variations

Test with empty data, partial data, and malformed responses to ensure your app handles all possible scenarios.