Seeded Reproducibility
Every probability roll inside Chaos Maker flows through a seeded PRNG. With the same seed and the same interaction sequence, Chaos Maker emits the same sequence of ChaosEvent decisions.
await injectChaos(page, { seed: 12345, network: { failures: [{ urlPattern: '/api/orders', statusCode: 503, probability: 0.5 }], },});Auto-generated seeds
Section titled “Auto-generated seeds”When seed is omitted, Chaos Maker auto-generates a 32-bit seed during instance creation. Read it from the adapter and print it on failure.
import { formatSeedReproduction, getChaosSeed } from '@chaos-maker/playwright';
const seed = await getChaosSeed(page);console.error(formatSeedReproduction(seed));See Reproduce a flaky failure for complete afterEach examples.
Replay boundaries
Section titled “Replay boundaries”The seed freezes Chaos Maker decisions:
- Which matching rule wins each probability roll.
- Whether
probabilityapplies or misses. - Which
onNth,everyNth, andafterNcounter checks pass for the same action order. - Which corruption strategy applies when the selected rule has one.
- The emitted chaos event sequence, ignoring wall-clock
timestampvalues.
The seed does not freeze the rest of the world:
- Browser scheduling and task timing.
- Wall-clock timestamps.
- App-side state from storage, caches, or previous tests.
- Network ordering created by the application under test.
- Third-party services or real backend responses.
- Assertions that depend on elapsed time instead of observable UI or log state.
For replay, drive the same user actions in the same order and assert the chaos log shape, not exact timestamps. When a rule still does not fire, turn on debug: true and follow Diagnose no chaos.
To capture the seed plus the full decision sequence as a single shareable artifact, see Timeline and reporting. formatReportHtml includes the same formatSeedReproduction line in meta.replaySnippet so the report doubles as a replay handle.