Presets
Presets are reusable ChaosConfig objects exported from @chaos-maker/core.
import { presets } from '@chaos-maker/core';import { injectChaos } from '@chaos-maker/playwright';
await injectChaos(page, presets.slowNetwork);When to use presets
Section titled “When to use presets”Use presets for smoke coverage and exploratory resilience tests. Use explicit configs for product-critical flows where the exact status code, selector, message direction, and probability matter.
Common pattern
Section titled “Common pattern”await injectChaos(page, { ...presets.unstableApi, seed: 42,});The seed belongs at the root config level, so it can be added to any preset before injection.
Built-in presets
Section titled “Built-in presets”| Preset | Surface | Use case |
|---|---|---|
unstableApi | Network | Occasional API failures and latency. |
slowNetwork | Network | All requests are delayed. |
offlineMode | Network | Requests fail like an offline browser. |
flakyConnection | Network | Rare aborts and latency. |
degradedUi | UI | Buttons and links are disabled or hidden. |
unreliableWebSocket | WebSocket | Drops, delays, and corrupts socket messages. |
unreliableEventStream | SSE | Drops, delays, and occasionally closes EventSource streams. |
Presets are plain config objects. You can spread them and add a seed or extra rules.