Register a custom WebdriverIO service with separate launcher and worker lifecycle hooks in wdio.conf.js

domain: browser-automation · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Add the service to the `services` array in wdio.conf.js as an imported class or string plus an options object: `services: [[CustomService, { someOption: true }]]`
  2. Export a worker-scoped service class as default and a launcher-scoped class as `export const launcher = CustomLauncherService` — the two run in separate processes and cannot share in-memory state
  3. Implement launcher-only hooks (`onPrepare`, `onWorkerStart`, `onWorkerEnd`, `onComplete`) for setup/teardown that should run once for the whole test run
  4. Implement worker hooks (`beforeSession`, `before`, `beforeTest`, `afterTest`, `after`, `afterSession`, etc.) for per-worker/per-test behavior
  5. Throw a `SevereServiceError` (imported from the `webdriverio` package) inside a hook to abort the run immediately; a plain `Error` is only logged and the run continues
  6. Publish reusable services under the `wdio-*-service` npm naming convention with `wdio-plugin`/`wdio-service` keywords so users can reference them by short name in `services`

Known gotchas

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans