File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
docs/react-testing-library Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -286,7 +286,28 @@ using Create React App without TypeScript, save this to `jsconfig.json` instead.
286
286
}
287
287
}
288
288
```
289
+
290
+ ### Jest 27
289
291
292
+ If you're using a recent version of Jest (27 or later), ` jsdom ` is no longer the
293
+ default environment. You can enable ` jsdom ` globally by editing ` jest.config.js ` :
294
+
295
+ ``` diff title="jest.config.js"
296
+ module.exports = {
297
+ + testEnvironment: 'jest-environment-jsdom',
298
+ // ... other options ...
299
+ }
300
+ ```
301
+
302
+ Or if you only need ` jsdom ` in some of your tests, you can enable it as and when
303
+ needed using [ docblocks] ( https://jestjs.io/docs/configuration#testenvironment-string ) :
304
+
305
+ ``` js
306
+ /**
307
+ * @jest-environment jsdom
308
+ */
309
+ ```
310
+
290
311
### Jest 24 (or lower) and defaults
291
312
292
313
If you're using the Jest testing framework version 24 or lower with the default
@@ -315,7 +336,7 @@ If you're running your tests in the browser bundled with webpack (or similar)
315
336
then ` React Testing Library ` should work out of the box for you. However, most
316
337
people using React Testing Library are using it with the Jest testing framework
317
338
with the ` testEnvironment ` set to ` jest-environment-jsdom ` (which is the default
318
- configuration with Jest).
339
+ configuration with Jest 26 and earlier ).
319
340
320
341
` jsdom ` is a pure JavaScript implementation of the DOM and browser APIs that
321
342
runs in Node. If you're not using Jest and you would like to run your tests in
You can’t perform that action at this time.
0 commit comments