Instructions for WebdriverIO Testrunner and TypeScript
Configuring your tests with WebdriverIO Testrunner and TypeScript
-
In the root level of your testing folder, install the
@axe-core/watcher
package and all of its dependencies usingnpm
or your preferred package manager (for example,yarn
orpnpm
).npm install --save-dev @axe-core/watcher
-
In your
wdio.config.ts
file, import thewdioTestRunner()
function, thewrapWdio()
function, and theWdioController
class from@axe-core/watcher
:import { wdioTestRunner, wrapWdio, WdioController } from '@axe-core/watcher'
-
Before exporting your WebdriverIO configuration, wrap it with a call to
wdioTestRunner()
while providing your API key:// Original code: export const config = { // Your config options here... } // Becomes: const API_KEY = process.env.API_KEY export const config = wdioTestRunner({ axe: { apiKey: API_KEY }, { // Your config options here... } })
-
In your test setup code (typically in a
before
orbeforeAll
block), create an instance of theWdioController
class, and then wrap yourbrowser
object:const controller = new WdioController(browser) 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
afterFetch
block):afterEach(async () => { await controller.flush() })