Axe API integration with Jest and Puppeteer#13241
Conversation
73baa4d to
5645f37
Compare
f66adb2 to
e052132
Compare
|
Logs with accessibility violations (closer to the end of file) for jobs without popular plugins and author role:
To test it locally try the following diff: diff --git a/packages/tests-e2e/support/setup-test-framework.js b/packages/tests-e2e/support/setup-test-framework.js
index cc8168644da..89cfc37b127 100644
--- a/packages/tests-e2e/support/setup-test-framework.js
+++ b/packages/tests-e2e/support/setup-test-framework.js
@@ -162,6 +162,7 @@ beforeAll( async () => {
} );
afterEach( async () => {
+ await expect( page ).toPassAxeTests();
await setupBrowser();
} ); |
e85c171 to
d9699bb
Compare
|
This is ready for review. This PR in the final version adds only new package which exposes the async matcher to validate whether a given page or its part is accessible according to Axe tool analysis. @stephenmathieson and @dylanb, I would appreciate your feedback on this one as it's based on |
greatislander
left a comment
There was a problem hiding this comment.
I've proposed some changes based on concerns that the function name and documentation could lead users to think that running Axe alone can accurately determine whether or not a page is accessible. Any automated accessibility tool can only catch a certain subset of potential accessibility issues, and must be combined with manual evaluation. It is probably better not to use language like:
expect( page ).toBeAccessible();But rather to use documentation and function names which indicates that the evaluation is based on criteria of this specific tool, e.g.:
expect( page ).toPassAxeTests();Open to and grateful for other ideas of how to frame this.
Totally agree with your reasoning 👍 I didn't think about it at all. I was too focused on the technical aspects. Thanks for your review. I applied all the changes you proposed as they better explain the intents of this new Jest matcher introduced. I'm not 100% sure if expect( page ).toPassAxeChecks();
expect( page ).toPassAxeAnalysis();
expect( page ).toPassAxeVerification();We can totally proceed as is if there isn't a better proposal. |
|
@gziolo thanks for accepting the suggestions! I hear the concern around using expect( page ).toPassAxeChecks();I also thought of: expect( page ).toPassAxeAudit();Open to other suggestions too. |
aduth
left a comment
There was a problem hiding this comment.
The messaging of a failing test is non-conventional, with only an "Error" text being highlighted. In direct conversation, it was mentioned this is a bug present in Jest for the moment. Pending @gziolo to share.
In the meantime, this appears good as it stands. 👍
f96302a to
d8c0c28
Compare
d8c0c28 to
81ea2c5
Compare
Co-Authored-By: gziolo <grzegorz@gziolo.pl>
|
I am a little late on this but this looks like great progress |
|
@gziolo seems like a good improvement would be to publish a |
|
This is going to be published to npm as |
* Axe API integration with Jest and Puppeteer * Implement expect matcher for accessibility checks * Docs: Add documentation for jest-puppeteer-axe package * Apply suggestions from code review Co-Authored-By: gziolo <grzegorz@gziolo.pl>
* Axe API integration with Jest and Puppeteer * Implement expect matcher for accessibility checks * Docs: Add documentation for jest-puppeteer-axe package * Apply suggestions from code review Co-Authored-By: gziolo <grzegorz@gziolo.pl>
Description
Implementation based on #12743.
Hopefully this is th final try to include
axeintegration with out e2e tests setup. This PR introduces newJestmatcher which takes aPuppeteerpageinstance and check if it is accesible as shown below:How has this been tested?
npm run test-e2ewith the following patch applied in addition to those changes:Types of changes
New feature for e2e testing.
Known issues
There is a bug in Jest with async matcher which makes them print differently than regular matchers. See jestjs/jest#7066 for more details. They are working on a fix and it looks like it might land in the next major release of Jest.
Checklist: