-
Notifications
You must be signed in to change notification settings - Fork 95
Cypress AXE accessibility testing
Cypress AXE is an integration of the AXE accessibility testing library with the Cypress testing framework to perform automated accessibility testing of web applications. The tests can be run both from the command line and through the Cypress AXE GUI.
(Assuming that Skosmos is installed correctly and its dependencies are up to date)
npm install
- In the file cypress.config.js located in the root of Skosmos, set the baseUrl to match the Skosmos configuration you are using.
- Run:
npm run test-accessibility-gui-all
- In the opened window, select E2E Testing
- Select the browser
- In the opened testing browser, open Inspector (Chrome & Firefox:
ctrl-shift-I
) - Click on the desired test from the list and observe the console, where a table of test results will appear
- Click on the notifications in the TEST BODY section of the Specs to see in the console the list of any issues and pay close attention to the Description field.
- Close the testing browser
- In the command line:
ctrl-c
- To run all tests, execute:
npm run test-accessibility-cli-all
- Monitor the output, where you will see a table of potential issues for each test
- If you want to run an individual test, look for the script name to run in the package.json file (located at the root of Skosmos)
- Example run for an individual test:
npm run test-accessibility-cli-landing
You can take inspiration from the previous tests done in Skosmos. The current categorization of usability tests is based on Skosmos templates, and it is advisable to follow this approach as closely as feasible. In practice, it is better to expand existing tests, but if needed and sensible, new tests can also be created.
Keep accessibility tests separate from Cypress tests, meaning they should be placed in the directory cypress/e2e/accessibility-tests or in a subdirectory named appropriately.
Ensure the functionality of tests in both the Cypress AXE GUI and the command line. In both cases, verify that the test works when running all tests as well as when running tests individually.
For assistance in creating tests, you can explore the following resources:
- https://github.com/component-driven/cypress-axe
- https://timdeschryver.dev/blog/setting-up-cypress-with-axe-for-accessibility#automating-a-whole-website
- axe-core
- cypress
- cypress-axe