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.
DESCRIPTION
This adds pa11y-ci with some scripts to run pa11y on various environments to test for accessibility.
pa11y-ci uses pa11y to run its tests; by default it runs WCAG2AA which is actually WCAG 2.1 AA according to the comment in this pull request.
With this update, we're adding a new set of config variables to our package file:
Obviously, these would be updated for each project but I wanted to have them set in place at the onset so it's an easy path to replacement.
This also includes adding new scripts to utilize those config variables:
pa11y itself runs a test on a single page. pa11y-ci adds the ability to run a test on a sitemap. As WordPress should be creating a sitemap by default, we can assume that each of the environment URLs will have a sitemap generated. You shouldn't have to change these scripts at all since they pull from the variables, but you may need to add more config variables and more scripts if you have additional environments.
This also includes an update to our
sync
function to replace the hardcoded URL with a variable so you don't need to worry about replacing URLs in multiple places:OTHER
STEPS TO VERIFY
npm i --legacy-peer-deps
npm run a11y:local
Right now, the results are just dumping into the command line.
There are additional ways to output results, like as JSON or HTML. We could discuss whether or not we'd want to add that for this now, or see if it's something we'd want to add down the road if it would add value. I haven't been able to really figure out how to get this to work for HTML, but I can dump JSON results to the console. Maybe we could use this as a way to parse JSON and automate the creation of Jira tickets for projects?
DOCUMENTATION
Will this pull request require updating the wd_s wiki?
For sure! If approved, we'll add a new page to the wiki to outline the setup and use of this.