File tree Expand file tree Collapse file tree 3 files changed +6
-28
lines changed Expand file tree Collapse file tree 3 files changed +6
-28
lines changed Original file line number Diff line number Diff line change @@ -207,25 +207,10 @@ See a working example of `update` in the
207207
208208Unmounts 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
224214Failing 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
226216errors 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.
Original file line number Diff line number Diff 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
9593For more information, see [ Helpers API] ( dom-testing-library/api-helpers.md )  and
9694[ Config API] ( dom-testing-library/api-configuration.md ) .
Original file line number Diff line number Diff 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' 
3333import  Component  from  ' ./Component.vue' 
3434
35- //  automatically unmount and cleanup DOM after the test is finished.
36- afterEach (cleanup)
37- 
3835test (' 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' 
7976import  Component  from  ' ./Component.vue' 
8077
81- afterEach (cleanup)
82- 
8378test (' properly handles v-model' async  () =>  {
8479 const  { getByLabelText , getByText  } =  render (Component)
8580
                         You can’t perform that action at this time. 
           
                  
0 commit comments