Instructions for WebdriverIO and TypeScript
Configuring your tests with WebdriverIO and TypeScript
-
In the root level of your testing folder, install the
@axe-core/watcherpackage and all of its dependencies usingnpmor your preferred package manager (for example,yarnorpnpm).npm install --save-dev @axe-core/watcher -
In your test files, import the
wdioConfig()function, thewrapWdio()function, and theWdioControllerclass from@axe-core/watcher:import { wdioConfig, wrapWdio, WdioController } from '@axe-core/watcher' -
In your test setup code (typically in a
beforeorbeforeAllblock), wrap any existing code for creating abrowserinstance with a call towdioConfig(), while providing your API key:const API_KEY = process.env.API_KEY const browser = await remote( wdioConfig({ axe: { apiKey: API_KEY } }) ) -
Once you have a
browserinstance, create an instance of theWdioControllerclass:const controller = new WdioController(browser); -
Wrap your
browserinstance with thewrapWdio()function, providing thebrowserinstance and thecontrollerinstance:wrapWdio(browser, controller) -
Finally, ensure all test results from axe Watcher are flushed out. To do this, add the following block of code to your test teardown code (typically in an
afterEachblock):afterEach(async () => { await controller.flush() })
