Skip to content

Commit

Permalink
docs: document resetAutoDestroyState method (#1674)
Browse files Browse the repository at this point in the history
  • Loading branch information
xanf committed Sep 8, 2020
1 parent 99948f5 commit 89f0ac0
Showing 1 changed file with 30 additions and 0 deletions.
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
})
})
```

0 comments on commit 89f0ac0

Please sign in to comment.