Chaos Modes

Chaos Modes

Chaos Modes let you change how your MockLab WebSocket project delivers events without touching a single line of your real backend. Switch modes from the project Settings tab and instantly test how your frontend handles failures, errors, and latency spikes.

Available modes

Success (default) All plans

Events are delivered normally with the exact payload you defined. No modifications, no delays. This is the default mode for all new projects.

// Client receives the exact payload you defined
{
  "orderId": "ord_9kXz",
  "status": "shipped",
  "trackingNumber": "1Z999AA10123456784"
}
Error mode Pro only

MockLab wraps every event payload in a standardized error envelope before sending it. Your original payload is preserved inside the original field. Use this to test how your frontend handles server error responses.

// Client receives the payload wrapped in an error envelope
{
  "error": true,
  "code": "INTERNAL_SERVER_ERROR",
  "message": "An unexpected error occurred",
  "timestamp": "2024-11-05T14:30:00.000Z",
  "original": {
    "orderId": "ord_9kXz",
    "status": "shipped",
    "trackingNumber": "1Z999AA10123456784"
  }
}

Your frontend should handle this by checking data.error === true before processing the payload.

Slow mode Pro only

MockLab adds a random delay of 1.5 to 3 seconds before delivering each event. The payload is delivered unchanged — only the timing changes. Use this to test loading states, timeout handling, and UI responsiveness under latency.

// Client receives the exact same payload, but 1.5–3s later than triggered
// No code change needed — just observe your loading states and timeouts

socket.on('order:updated', (data) => {
  // This fires 1.5–3s after the event is triggered
  setLoading(false);
  updateOrderStatus(data.status);
});

Switching modes

  1. Open your WS project and click the Settings tab.
  2. Under Scenario mode, select Success, Error, or Slow.
  3. Click Save. The mode takes effect immediately for all subsequent event deliveries.
  4. Connected clients are not disconnected — they simply receive the next event in the new mode.
Chaos modes are per-project. You can run multiple projects simultaneously — one in Success mode for integration tests and one in Error mode for resilience tests.

Testing checklist

Use these scenarios to validate your frontend's resilience:

Error Your app shows an error message instead of processing the payload
Error Error state is cleared when the next successful event arrives
Slow Loading spinners or skeleton states appear while waiting
Slow Your timeout logic fires correctly (if configured)
Slow The UI doesn't freeze or become unresponsive during the delay
Success All normal event types are handled and the UI updates correctly