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
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"
}
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.
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
- Open your WS project and click the Settings tab.
- Under Scenario mode, select Success, Error, or Slow.
- Click Save. The mode takes effect immediately for all subsequent event deliveries.
- Connected clients are not disconnected — they simply receive the next event in the new mode.
Testing checklist
Use these scenarios to validate your frontend's resilience: