You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `afterEach(cleanup)` call also works in `describe` blocks:
141
+
142
+
```jsx
143
+
describe('when logged in', () => {
144
+
afterEach(cleanup)
145
+
146
+
it('renders the user', () => {
147
+
render(<SiteHeader />)
148
+
// ...
149
+
});
150
+
})
151
+
```
152
+
153
+
Failing to call `cleanup` when you've called `render` could result in a memory leak and tests which are not "idempotent" (which can lead to difficult to debug errors in your tests).
154
+
155
+
The alternative to `cleanup` is balancing every `render` with an `unmount` method call.
0 commit comments