Note: If you want to manually perform a quick audit on your websites using Axe, there is a chrome browser extension that you can install to enable the audit tool in your DevTools.
Add Axe dependency in your project with the following CLI command
npm install axe-core axe-testcafe --save-dev
Include accessibility assertion in your existing testcafe e2e tests or create a new test for this purpose.
That’s it! your test is ready to be executed (axe.js is the test file that contains the above test)
npx testcafe chrome tests/axe.js
The test failed because the website (QA-Practice) failed some of the accessibility validations. The test results report looks like this:
Optional Config Step
Axe module allows you to define the context and options (e.g. to apply rules/exclude some HTML tags from the audit process).