Skip to content

Commit 1efd327

Browse files
Kent C. Doddsafontcu
Kent C. Dodds
andauthored
Update setup.md (#215)
* Update setup.md * Update docs/react-testing-library/setup.md Co-Authored-By: Adrià Fontcuberta <[email protected]>
1 parent 2826b12 commit 1efd327

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/react-testing-library/setup.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,25 @@ the `RTL_SKIP_AUTO_CLEANUP` env variable to 'true'. You can do this with
285285
```
286286
cross-env RTL_SKIP_AUTO_CLEANUP=true jest
287287
```
288+
289+
To make this even easier, you can also simply import
290+
`@testing-library/react/dont-cleanup-after-each` which will do the same thing.
291+
Just make sure you do this before importing `@testing-library/react`. You could
292+
do this with Jest's `setupFiles` configuration:
293+
294+
```js
295+
{
296+
// ... other jest config
297+
setupFiles: ['@testing-library/react/dont-cleanup-after-each']
298+
}
299+
```
300+
301+
Or with mocha's `-r` flag:
302+
303+
```
304+
mocha -r @testing-library/react/dont-cleanup-after-each
305+
```
306+
307+
Alternatively, you could import `@testing-library/react/pure` in all your
308+
tests that you don't want the `cleanup` to run and the `afterEach` won't
309+
be setup automatically.

0 commit comments

Comments
 (0)