Skip to content

WebdriverIO Adapter

Use @chaos-maker/webdriverio for WDIO suites that can inject chaos after navigation.

import {
injectChaos,
removeChaos,
getChaosLog,
getChaosSeed,
registerChaosCommands,
registerSWChaosCommands,
} from '@chaos-maker/webdriverio';
FunctionPurpose
injectChaos(browser, config)Injects the core UMD into the current page.
removeChaos(browser)Stops chaos in the current page.
getChaosLog(browser)Returns ChaosEvent[].
getChaosSeed(browser)Returns the active seed or null.
registerChaosCommands(browser)Adds browser.injectChaos(), browser.removeChaos(), browser.getChaosLog(), and browser.getChaosSeed().
registerSWChaosCommands(browser)Adds browser.injectSWChaos(config, options?), browser.removeSWChaos(options?), browser.getSWChaosLog(), and browser.getSWChaosLogFromSW(options?).

Call after browser.url(). WebDriver does not expose a reliable cross-browser pre-navigation hook, so initial page-load requests are outside this adapter’s reach.

await browser.url('/dashboard');
await injectChaos(browser, config);
await $('#reload').click();

For first-load interception, use Playwright or Cypress.

SSE chaos and GraphQL operation matching work when the EventSource or request is created after injection. For Service Worker chaos, call browser.url(), wait for navigator.serviceWorker.controller, then call browser.injectSWChaos(config).