Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(react-testing-library): warn about afterEach auto cleanup footgun #779

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/react-testing-library/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ require that you use Jest).
Adding options to your global test config can simplify the setup and teardown of
tests in individual files.

## Safe cleanup

`React Testing Library` will auto `cleanup` rendered components in all
frameworks that expose an `afterEach` API. Be warned, however, that any `async`
`afterEach` handlers you register that _defers_ the RTL `cleanup` call will
leave opporitunity for your rendered components to continue process react state
updates and emit `act()` errors. If you implement custom async `afterEach`
handlers, it is recommended to call `cleanup` explicity before any async
behavior.

## Custom Render

It's often useful to define a custom render method that includes things like
Expand Down