Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This assertion, based on
jest-puppeteer-axe
, allows you to check a page using the axe accessibility linter.The output is a little nicer than jest-puppeteer-axe's because it shows the markup of the elements which are breaking axe rules (as opposed to a non-unique CSS selector), so it is easier to figure out which elements need to be fixed. In the browser, you can click on the markup to see the relevant elements in the devtools elements panel.
Documentation
Here's what the output looks like in the CLI:
Here's what it looks like in the browser:
Testing
Run the tests in watch mode:
Note: the HTML syntax highlighting in the CLI output isn't shown when Pleasantest runs in its own test suite. This is so that the test snapshots are still readable and don't get covered with escape codes for coloring.
Test the browser output by changing
tests/accessibility/toPassAxeTests.test.ts
to usewithBrowser.headed
instead ofwithBrowser
. Then it should open a browser for the test, and close it once it passes. To make the test fail so you can see the failure message in the browser, under theutils.injectHTML(...)
line add a new line: