-
Notifications
You must be signed in to change notification settings - Fork 9
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
Experimental PR: Research spike - Cypress + Accessibility testing #1675
Conversation
…hat goes thru 7 pages
…est practice, a11y
The latest: Tests run fine locally, but return different results on GitHub Actions. Namely, they always pass when they should not be! I tried adding an explicit support file, adding logging, re-writing the entire Action, but none of those fixed it. Not really sure what the issue is. Also didn't work: Running in headed mode (as opposed to headless Chrome). |
Experiment is over! Closing + full write-up will be out by end of week. |
🚧 🚧 🚧 This is an experimental research spike PR 🚧 🚧 🚧
What this PR does
accessibility.cy.js
that goes through 7 pages (home, agency home, eligibility, elig start, enrollment index, enrollment success, help) of the app and runs each of the following tests on each page.Comparing the tools locally
Initial reading
So, I stand by my original conclusion, that we should use both PA11Y and axe-core. But it looks like the implementation of using both is actually so easy that you'd be a fool not to.
Testing method
pa11y
npm command line tool: https://github.com/pa11y/pa11ypa11y
on the command line on all 7 pages for pages on localhost (doesn't have reCaptcha, has dev debug bar) and test (has reCaptcha).Results:
pa11y
on the command line is very fast. Returns results like this:Preliminary findings
Like the blog posts above asserted, the tools find different errors. I was impressed that pa11y was able to find the Skip Nav color constrast bug, even though I never told the tool to go focus on it or click tab. The Axe tool didn't find the Skip Nav color contrast bug. But it did find "Best Practice" bugs that pa11y doesn't have, like how all page content is contained by landmarks. I came away thinking we should be using both tools in development - b/c both tools - command line and Firefox / Chrome extension are quite fast -- much faster than running a full Google Lighthouse test. (Lighthouse performance testing adds a lot of time.) Also, if the tools are easy enough to integrate into Cypress and reliable, it's worth while to add them both to the CI test suite as well.
Axe flags
Lighthouse, meanwhile, returns a score of 100 for accessibility - even though both pa11y and Axe found error level issues. So it might not be worth it to run Lighthouse for accessibility in addition to the 2 other tools.
Lastly, it's pretty helpful that the pa11y error message suggested an alternate color for the insufficient contrast.
#005681
is really close to what we have.Comparing the tools in Cypress
Installing and configuring tooling
Testing
before()
Lighthouse issues
Performance test is flakey and returns different results after repeated runs.
Pa11y issues
The Pa11y color contrast rule seems to be catching more things than I think it should.
This is flagging the H1 and H2 as insufficient contrast, but I think it's because the image in the background isn't showing up.
This is flagging the Previous Page button as insufficent contrast. But even the pa11y command line tool doesn't find this or flag this - it only flags the Skip Nav. So we're getting different errors depending on whether running in the CLI or Cypress. Perhaps this will all disappear if we just change the Skip Nav color.
The Pa11y library is supposed to allow you to ignore certain rules. I tried adding an
ignore:
for the color contrast rule here https://github.com/cal-itp/benefits/compare/spike/cypress-a11y?expand=1#diff-8bcefc461aeb1ada5582435f5b2427508a858457bbc046a7a968dc0e1b76c222R8, but I don't think it's working properly in the test runner. It works fine locally for me though:So that's why I set the
threshold
to a higher number of 4 to allow the tests to pass.Evaluation
Conclusion
For Cypress, I think we should keep
axe
but ditchcypress-audit
(pa11y
andlighthouse
). Though I appreciate that thepa11y
tool found the Skip Nav bug, the color contrast rule onpa11y
has too many false positives when running in Cypress. We can still use the tool locally during the development of new components with new color combinations. Color contrast is also being checked in Figma at earlier parts of the design phase. Since theaxe
testing is more sensitive thanlighthouse
for accessibility, I don't think we need to add any more newlighthouse
testing. I think keeping the Lighthouse tests as it is, for the home page, help page, is sufficient for testing performance and best practices. For the other pages with forms, theaxe
tool is a much more thorough test than Lighthouse.What's next
Possible next steps: