Instructions for WebdriverIO Testrunner and JavaScript
Configuring your tests with WebdriverIO Testrunner and JavaScript
-
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
wdio.config.jsfile, import thewdioTestRunner()function, thewrapWdio()function, and theWdioControllerclass from@axe-core/watcher:const { wdioTestRunner, wrapWdio, WdioController } = require('@axe-core/watcher') -
Before exporting your WebdriverIO configuration, wrap it with a call to
wdioTestRunner()while providing your API key:exports.config = { // Your config options here... } // Becomes: exports.config = wdioTestRunner({ axe: { apiKey: process.env.API_KEY }, { // Your config options here... } }) -
In your test setup code (typically in a
beforeorbeforeAllblock), create an instance of theWdioController, and then wrap yourbrowserobject: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
afterFetchblock):afterEach(async () => { await controller.flush() })
