Skip to content

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);

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.

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.

PresetSurfaceUse case
unstableApiNetworkOccasional API failures and latency.
slowNetworkNetworkAll requests are delayed.
offlineModeNetworkRequests fail like an offline browser.
flakyConnectionNetworkRare aborts and latency.
degradedUiUIButtons and links are disabled or hidden.
unreliableWebSocketWebSocketDrops, delays, and corrupts socket messages.
unreliableEventStreamSSEDrops, delays, and occasionally closes EventSource streams.

Presets are plain config objects. You can spread them and add a seed or extra rules.