Skip to content

docs: document resetAutoDestroyState method, fix #1638 #1674

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

Merged
merged 1 commit into from
Sep 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/api/enableAutoDestroy.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,33 @@ describe('Foo', () => {
})
})
```

## resetAutoDestroyState

- **Usage:**

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)

To achieve this you might call `resetAutoDestroyState` to disable previously registered hook

```js
import {
enableAutoDestroy,
resetAutoDestroyState,
mount
} from '@vue/test-utils'
import Foo from './Foo.vue'

// calls wrapper.destroy() after each test
enableAutoDestroy(afterEach)
// resets auto-destroy after suite completes
afterAll(resetAutoDestroyState)

describe('Foo', () => {
it('renders a div', () => {
const wrapper = mount(Foo)
expect(wrapper.contains('div')).toBe(true)
// no need to call wrapper.destroy() here
})
})
```