Skip to content

Commit d632fcb

Browse files
authored
Merge pull request testing-library#320 from testing-library/remove-cleanup
Remove cleanup() references from Vue docs
2 parents 850cb0e + f1d5262 commit d632fcb

File tree

3 files changed

+6
-28
lines changed

3 files changed

+6
-28
lines changed

docs/vue-testing-library/api.md

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -207,25 +207,10 @@ See a working example of `update` in the
207207

208208
Unmounts Vue trees that were mounted with [render](#render).
209209

210-
```jsx
211-
import { cleanup, render } from '@testing-library/vue'
212-
import Component from './Component.vue'
213-
214-
afterEach(cleanup) // <-- add this
215-
216-
test('renders into document', () => {
217-
render(Component)
218-
// ...
219-
})
220-
221-
// ... more tests ...
222-
```
210+
> If you are using an environment that supports `afterEach` hook (as in Jest),
211+
> there's no need to call `cleanup` manually. Vue Testing Library handles it for
212+
> you.
223213
224214
Failing to call `cleanup` when you've called `render` could result in a memory
225-
leak and tests which are not "idempotent" (which can lead to difficult to debug
215+
leak and tests which are not idempotent (which can lead to difficult to debug
226216
errors in your tests).
227-
228-
**If you don't want to add this to _every single test file_** then we recommend
229-
that you configure your test framework to run a file before your tests which
230-
does this automatically. See the [setup](./setup) section for guidance on how to
231-
set up your framework.

docs/vue-testing-library/cheatsheet.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ For more information, see [Events API](dom-testing-library/api-events.md)
8989
to it: `within(getByTestId("global-header")).getByText("hello")`.
9090
- **configure(config)** change global options:
9191
`configure({testIdAttribute: 'my-test-id'})`.
92-
- **cleanup()** clears the DOM ([use with `afterEach`](setup.md#cleanup) to
93-
reset DOM between tests).
9492

9593
For more information, see [Helpers API](dom-testing-library/api-helpers.md) and
9694
[Config API](dom-testing-library/api-configuration.md).

docs/vue-testing-library/examples.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,9 @@ title: Examples
2929
```
3030

3131
```js
32-
import { render, fireEvent, cleanup } from '@testing-library/vue'
32+
import { render, fireEvent } from '@testing-library/vue'
3333
import Component from './Component.vue'
3434

35-
// automatically unmount and cleanup DOM after the test is finished.
36-
afterEach(cleanup)
37-
3835
test('increments value on click', async () => {
3936
// The render method returns a collection of utilities to query your component.
4037
const { getByText } = render(Component)
@@ -75,11 +72,9 @@ test('increments value on click', async () => {
7572
```
7673

7774
```js
78-
import { render, fireEvent, cleanup } from '@testing-library/vue'
75+
import { render, fireEvent } from '@testing-library/vue'
7976
import Component from './Component.vue'
8077

81-
afterEach(cleanup)
82-
8378
test('properly handles v-model', async () => {
8479
const { getByLabelText, getByText } = render(Component)
8580

0 commit comments

Comments
 (0)