Skip to content

Commit

Permalink
Merge pull request #44 from kentcdodds/pr/extend-expect
Browse files Browse the repository at this point in the history
Add extend-expect file
  • Loading branch information
NickColley authored Sep 4, 2018
2 parents 86fc066 + 65495a0 commit 268211c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ it('should demonstrate this matcher`s usage', async () => {

![Screenshot of the resulting output from the usage example](example-cli.png)

> Note, you can also simply require `'jest-axe/extend-expect'` which will call `expect.extend` for you.
> This is especially helpful when using the jest `setupFiles` configuration.
### With React

```javascript
Expand Down
8 changes: 8 additions & 0 deletions extend-expect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// this allows users to simply add `require('jest-axe/extend-expect')`
// at the top of their test file rather than have two lines for this.
// it also allows users to use jest's setupFiles configuration and
// point directly to `jest-axe/extend-expect`
const { toHaveNoViolations } = require('jest-axe')

expect.extend(toHaveNoViolations)

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"repository": "nickcolley/jest-axe",
"main": "index.js",
"files": [
"index.js"
"index.js",
"extend-expect.js"
],
"scripts": {
"test": "jest"
Expand Down

0 comments on commit 268211c

Please sign in to comment.