Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add a11y reporting using axe-puppeteer #12743

Closed

Conversation

stephenmathieson
Copy link

Happy WordCamp contributor day!

Description

This patch introduces accessibility testing using axe-puppeteer. Each one of the existing E2E tests now runs AxePuppeteer#analyze() on the relevant portion(s) of the DOM and outputs the returned a11y violations to stderr.

In time, as these accessibility problems are fixed, the logging could be replaced with assertions, ensuring no "new" problems are introduced into the codebase.

This patch is similar to #10695, but uses a more complete a11y testing tool and does not introduce new test failures.

How has this been tested?

Running npm run test-e2e locally.

Screenshots

screenshot of a11y violations

Types of changes

New testing features/utilities.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

Happy WordCamp contributor day!

This patch introduces accessibility testing using [`axe-puppeteer`](https://github.com/dequelabs/axe-puppeteer). Each one of the existing E2E tests now runs `AxePuppeteer#analyze()` on the relevant portion(s) of the DOM and outputs the returned a11y violations to stderr.

In time, as these accessibility problems are fixed, the logging could be replaced with assertions, ensuring no "new" problems are introduced into the codebase.

This patch is similar to WordPress#10695, but uses a more complete a11y testing tool and does not introduce new test failures.
@joemcgill joemcgill requested a review from a team December 9, 2018 21:51
@gziolo gziolo added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). labels Dec 9, 2018
@aduth
Copy link
Member

aduth commented Dec 12, 2018

Each one of the existing E2E tests now runs AxePuppeteer#analyze() on the relevant portion(s) of the DOM and outputs the returned a11y violations to stderr.

Would it not be reasonable to run the analysis on the entire document after every test case?

Purely from the perspective of the developer experience of authoring tests, I'd neither want this to be possible to overlook, nor a hurdle in making the decision on what should be tested.

@stephenmathieson
Copy link
Author

Hey Andrew,

Yes, it would absolutely be possible. We opted to only analyze the relevant portions of the DOM for a two major reasons:

  1. reduce duplicate issue count
  2. reduce the time spent doing analysis

If neither of these were a concern, we would have structured this differently. Rather than editing every test file, we'd just tap into the global afterEach hook and do something like:

afterEach(async () => {
  const axe = new AxePuppeteer(page)
  const results = await axe.analyze()
  logA11yResults(results)
})

This would have been much simpler, and would have found most of the relevant issues, but would have slowed down the test suite by more than a little and would produce a significant number of duplicate issues.

@gziolo
Copy link
Member

gziolo commented Jan 29, 2019

This was superseded by #13241, we still need to integrate new matcher with e2e test suite but this is going to be integrated in the way @aduth suggested:

Would it not be reasonable to run the analysis on the entire document after every test case?

Purely from the perspective of the developer experience of authoring tests, I'd neither want this to be possible to overlook, nor a hurdle in making the decision on what should be tested.

Thanks for all your excellent work done here which helped us to make it solid. Much appreciated. Your involvement a WC US and upfront preparation with axe-puppeteer was amazing ❤️

@gziolo gziolo closed this Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants