Skip to content

Commit

Permalink
Merge branch 'NickColley:main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
zcolleyz authored Mar 23, 2023
2 parents 17b4cb1 + 5bc8fd2 commit c4b0d34
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ You'll also need to:
- test your interface with the [assistive technologies that real users use](https://www.gov.uk/service-manual/technology/testing-with-assistive-technologies#when-to-test) (see also [WebAIM's survey results](https://webaim.org/projects/screenreadersurvey8/#primary)).
- include disabled people in user research.

### Checks that do not work in jest-axe

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

## Installation:
```bash
npm install --save-dev jest jest-axe jest-environment-jsdom
Expand Down Expand Up @@ -194,6 +198,25 @@ it('should demonstrate this matcher`s usage with a custom config', async () => {
})
```

### Testing isolated components

> All page content must be contained by landmarks (region)
When testing with aXe sometimes it assumes you are testing a page. This then results in unexpected violations for landmarks for testing isolation components.

You can disable this behaviour with the `region` rule:

```javascript
const { configureAxe } = require('jest-axe')

const axe = configureAxe({
rules: {
// disable landmark rules when testing isolated components.
'region': { enabled: false }
}
})
```

## Setting global configuration

If you find yourself repeating the same options multiple times, you can export a version of the `axe` function with defaults set.
Expand Down Expand Up @@ -273,10 +296,6 @@ 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

0 comments on commit c4b0d34

Please sign in to comment.