Skip to content
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

Disable axe color contrast checks #252

Merged
merged 2 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ module.exports = axe

Refer to [Developing Axe-core Rules](https://github.com/dequelabs/axe-core/blob/master/doc/rule-development.md) for instructions on how to develop custom rules and checks.

## Checks that do not work in jest-axe

Color contrast checks do not work in JSDOM so are turned off in jest-axe.

## Thanks
- [Jest][Jest] for the great test runner that allows extending matchers.
- [axe](https://www.deque.com/axe/) for the wonderful axe-core that makes it so easy to do this.
Expand Down
17 changes: 13 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,20 @@ function configureAxe (options = {}) {

const { globalOptions = {}, ...runnerOptions } = options

// Set the global configuration for
// axe-core
// Set the global configuration for axe-core
// https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#api-name-axeconfigure
axeCore.configure(globalOptions)

const { checks = [], ...otherGlobalOptions } = globalOptions
axeCore.configure({
checks: [
{
// color contrast checking doesnt work in a jsdom environment.
id: 'color-contrast',
enabled: false
},
...checks
],
...otherGlobalOptions
})

/**
* Small wrapper for axe-core#run that enables promises (required for Jest),
Expand Down