Skip to content

Commit

Permalink
Merge pull request #252 from NickColley/disabled-broken-rule
Browse files Browse the repository at this point in the history
Disable axe color contrast checks
  • Loading branch information
NickColley authored Nov 2, 2022
2 parents 208e197 + 81a8e52 commit d55cd80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
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

0 comments on commit d55cd80

Please sign in to comment.