Skip to content

Commit 89f0ac0

Browse files
authored
docs: document resetAutoDestroyState method (#1674)
1 parent 99948f5 commit 89f0ac0

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

docs/api/enableAutoDestroy.md

+30
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,33 @@ describe('Foo', () => {
2323
})
2424
})
2525
```
26+
27+
## resetAutoDestroyState
28+
29+
- **Usage:**
30+
31+
After calling `enableAutoDestroy` you might need to disable auto-destroy behavior (for example when some of your test suites rely on wrapper being persistent across separate tests)
32+
33+
To achieve this you might call `resetAutoDestroyState` to disable previously registered hook
34+
35+
```js
36+
import {
37+
enableAutoDestroy,
38+
resetAutoDestroyState,
39+
mount
40+
} from '@vue/test-utils'
41+
import Foo from './Foo.vue'
42+
43+
// calls wrapper.destroy() after each test
44+
enableAutoDestroy(afterEach)
45+
// resets auto-destroy after suite completes
46+
afterAll(resetAutoDestroyState)
47+
48+
describe('Foo', () => {
49+
it('renders a div', () => {
50+
const wrapper = mount(Foo)
51+
expect(wrapper.contains('div')).toBe(true)
52+
// no need to call wrapper.destroy() here
53+
})
54+
})
55+
```

0 commit comments

Comments
 (0)