Skip to content

Latest commit

 

History

History

typescript-selenium-webdriver-sample

typescript-selenium-webdriver-sample

This sample demonstrates how you might set up a CI build for a simple, static html page to perform end to end accessibility tests in a browser, including how to suppress pre-existing or third-party failures using Jest Snapshot Testing.

This sample uses Selenium WebDriver for browser automation and uses the corresponding @axe-core/webdriverjs library to integrate Axe and Selenium. But you don't have to use Selenium to use Axe! If you prefer a different browser automation tool, you can still follow the same concepts from this sample by using the integration library appropriate for your framework:

Getting Started

The individual files in the sample contain comments that explain the important parts of each file in context.

Some good places to start reading are:

  • tests/index.test.ts: Jest test file that opens src/index.html in a browser with Selenium and runs accessibility scans against it with @axe-core/webdriverjs
  • azure-pipelines.yml: Azure Pipelines config file that sets up our Continuous Integration and Pull Request builds
  • jest.config.js: Jest configuration file that enables TypeScript (using ts-jest) and test result reporting in Azure Pipelines (using jest-junit)

Tools and libraries used

See it in action in Azure Pipelines

Build Status

The accessibility tests run as part of the yarn test build step:

Screenshot of "yarn test" build logs in sample build

The test pass/fail results display in the Tests tab of the build logs:

Screenshot of Tests tab in sample build

Detailed accessibility scan information also appears in the Scans tab, courtesy of the SARIF SAST Scans Tab extension:

Screenshot of Scans tab in sample build

See it in action on your local machine

  1. Install the stable version of Chrome

  2. Clone this sample repository

    git clone https://github.com/microsoft/axe-pipelines-samples
  3. Install the dependencies

    cd ./axe-pipelines-samples/typescript-selenium-webdriver-sample
    yarn install # or npm install, whichever your project prefers
  4. Run the tests!

    yarn test # or npm test

    Screenshot of yarn test command showing all tests passing