axe test helper - to reuse accessibility test fixures. If future these can be test options/types
This commit is contained in:
17
helpers/axe-test.js
Normal file
17
helpers/axe-test.js
Normal file
@@ -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;
|
||||
Reference in New Issue
Block a user