0.0.0 • Published 1 year ago
expect-no-axe-violations v0.0.0
Usage
This package works for any testing setup that uses expect
, including Jest and Playwright.
npm i expect-no-axe-violations --save-dev
import { toHaveNoAxeViolations } from "expect-no-axe-violations";
expect.extend(toHaveNoAxeViolations);
You'll now be able to use a .toHaveNoAxeViolations()
matcher on any value that contains a .violations
property, such as the result of calling axe()
:
const results = await axe(/* ... */);
expect(results).toHaveNoAxeViolations();
⚠️ This package does not run aXe on its own. It only provides a matcher to ensure there are no violations in aXe results. See the excellent NickColley/jest-axe for a package that does run aXe.
Setup with Jest
Instead of calling expect.extend
yourself, you can add expect-no-axe-violations/extend-expect.js
to setupFilesAfterEnv
to have extend
extended for you:
// jest.config.js
module.exports {
setupFilesAfterEnv: ['expect-no-axe-violations/extend-expect.js'],
};
Setup with Playwright
Use Playwright's globalSetup
option:
// global-setup.ts
import { toHaveNoAxeViolations } from "expect-no-axe-violations";
export default function globalSetup(config: FullConfig) {
expect.extend(toHaveNoAxeViolations);
}
Development
See .github/CONTRIBUTING.md
.
Thanks! 💖
Contributors
💙 This package is based on @JoshuaKGoldberg's template-typescript-node-package.
0.0.0
1 year ago