Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 617 Bytes

enableAutoDestroy.md

File metadata and controls

25 lines (18 loc) · 617 Bytes

enableAutoDestroy(hook)

  • Arguments:

    • {Function} hook
  • Usage:

enableAutoDestroy will destroy all created Wrapper instances using the passed hook function (for example afterEach).

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

// calls wrapper.destroy() after each test
enableAutoDestroy(afterEach)

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