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
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 }]]`
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
Implement launcher-only hooks (`onPrepare`, `onWorkerStart`, `onWorkerEnd`, `onComplete`) for setup/teardown that should run once for the whole test run
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
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
Launcher and worker services run in different processes, so global variables set in one are invisible to the other — pass data via files or env vars instead
A thrown plain Error in a hook won't stop the suite; only `SevereServiceError` halts the run, so accidental generic errors are silently logged while tests keep going
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?