Instructions for WebdriverIO and TypeScript

Link to Instructions for WebdriverIO and TypeScript copied to clipboard

Configuring your tests with WebdriverIO and TypeScript

Free Trial
  1. In the root level of your testing folder, install the @axe-core/watcher package and all of its dependencies using npm or your preferred package manager (for example, Yarn or pnpm).

    npm install --save-dev @axe-core/watcher
  2. In your test files, import the wdioConfig(), the wrapWdio() function, and the WdioController class from @axe-core/watcher:

    import {
      wdioConfig,
      wrapWdio,
      WdioController
    } from '@axe-core/watcher'
  3. In your test setup code (typically in a before or beforeAll block), wrap any existing code for creating a browser instance with a call to wdioConfig(), while providing your API key:

    const API_KEY = process.env.API_KEY
    
    const browser = await remote(
      wdioConfig({
        axe: {
          apiKey: API_KEY
        }
      })
    )
  4. Once you have a browser instance, create an instance of the WdioController class:

    const controller = new WdioController(browser);
  5. Wrap your browser instance with the wrapWdio() function, providing the browser instance and the controller instance:

    wrapWdio(browser, controller)
  6. 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 afterEach block):

    afterEach(async () => {
      await controller.flush()
    })