File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -116,11 +116,28 @@ file][]) and you're good to go:
116
116
https://jestjs.io/docs/en/configuration.html#setupfilesafterenv-array
117
117
118
118
``` javascript
119
+ // In your own jest-setup.js (or any other name)
119
120
import ' @testing-library/jest-dom'
121
+
122
+ // In jest.config.js add (if you haven't already)
123
+ setupFilesAfterEnv: [' <rootDir>/jest-setup.js' ]
120
124
```
121
125
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
+ ```
124
141
125
142
## Custom matchers
126
143
@@ -1167,6 +1184,7 @@ Thanks goes to these people ([emoji key][emojis]):
1167
1184
1168
1185
<!-- markdownlint-enable -->
1169
1186
<!-- prettier-ignore-end -->
1187
+
1170
1188
<!-- ALL-CONTRIBUTORS-LIST:END -->
1171
1189
1172
1190
This project follows the [ all-contributors] [ all-contributors ] specification.
You can’t perform that action at this time.
0 commit comments