Skip to content

Commit c686a78

Browse files
obedparlagnapse
andauthored
docs: Update usage in README to make it more copy-pasty (#326)
Co-authored-by: Ernesto García <[email protected]>
1 parent 70677a1 commit c686a78

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,28 @@ file][]) and you're good to go:
116116
https://jestjs.io/docs/en/configuration.html#setupfilesafterenv-array
117117

118118
```javascript
119+
// In your own jest-setup.js (or any other name)
119120
import '@testing-library/jest-dom'
121+
122+
// In jest.config.js add (if you haven't already)
123+
setupFilesAfterEnv: ['<rootDir>/jest-setup.js']
120124
```
121125

122-
> Note: If you're using TypeScript, make sure your setup file is a `.ts` and not
123-
> a `.js` to include the necessary types.
126+
### With TypeScript
127+
128+
If you're using TypeScript, make sure your setup file is a `.ts` and not a `.js`
129+
to include the necessary types.
130+
131+
You will also need to include your setup file in your `tsconfig.json` if you
132+
haven't already:
133+
134+
```json
135+
// In tsconfig.json
136+
"include": [
137+
...
138+
"./jest-setup.ts"
139+
],
140+
```
124141

125142
## Custom matchers
126143

@@ -1167,6 +1184,7 @@ Thanks goes to these people ([emoji key][emojis]):
11671184

11681185
<!-- markdownlint-enable -->
11691186
<!-- prettier-ignore-end -->
1187+
11701188
<!-- ALL-CONTRIBUTORS-LIST:END -->
11711189

11721190
This project follows the [all-contributors][all-contributors] specification.

0 commit comments

Comments
 (0)