Cypress Adapter
Use @chaos-maker/cypress to inject chaos into the next cy.visit() and inspect decisions through Cypress commands.
Register
Section titled “Register”import '@chaos-maker/cypress/support';Commands
Section titled “Commands”| Command | Purpose |
|---|---|
cy.injectChaos(config, options?) | Injects chaos into the next visit. |
cy.removeChaos() | Stops chaos in the current AUT window. |
cy.getChaosLog() | Yields ChaosEvent[]. |
cy.getChaosSeed() | Yields the active seed or null. |
cy.injectSWChaos(config, options?) | Sends config to the active Service Worker. |
cy.removeSWChaos(options?) | Stops Service Worker chaos. |
cy.getSWChaosLog() | Yields Service Worker chaos events buffered on the page. |
cy.getSWChaosLogFromSW(options?) | Yields chaos events pulled directly from the Service Worker. |
Persistence
Section titled “Persistence”By default, chaos persists across navigations until cy.removeChaos() runs. Pass { persistAcrossNavigations: false } to limit chaos to the next visit.
cy.injectChaos(config, { persistAcrossNavigations: false });cy.visit('/checkout');Timing
Section titled “Timing”Call cy.injectChaos() before cy.visit() so Cypress can install the bundle before app code executes.
For Service Worker chaos, call cy.visit() first, wait until navigator.serviceWorker.controller is present, then call cy.injectSWChaos() before the action that triggers SW fetches.
SSE chaos and GraphQL operation matching use the same cy.injectChaos() command as network, UI, and WebSocket chaos.