From 6d17cdacc14e38b42474085102de540a67b01cf3 Mon Sep 17 00:00:00 2001 From: Aarish <118203269+ImprobableGenius@users.noreply.github.com> Date: Thu, 22 May 2025 22:50:05 -0500 Subject: [PATCH] axe test helper - to reuse accessibility test fixures. If future these can be test options/types --- helpers/axe-test.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 helpers/axe-test.js diff --git a/helpers/axe-test.js b/helpers/axe-test.js new file mode 100644 index 0000000..a2136ee --- /dev/null +++ b/helpers/axe-test.js @@ -0,0 +1,17 @@ +const base = require('@playwright/test'); +const AxeBuilder = require('@axe-core/playwright').default; + +// Extend base test by providing "makeAxeBuilder" +// +// This new "test" can be used in multiple test files, and each of them will get +// a consistently configured AxeBuilder instance. +exports.test = base.test.extend({ + makeAxeBuilder: async ({ page }, use) => { + const makeAxeBuilder = () => new AxeBuilder({ page }) + .withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa']) + .exclude('#commonly-reused-element-with-known-issue'); + + await use(makeAxeBuilder); + } +}); +exports.expect = base.expect; \ No newline at end of file