You’re browsing the documentation for Vue Test Utils for Vue v2.x and earlier.

To read docs for Vue Test Utils for Vue 3, click here.

createWrapper(node [, options])

  • Arguments:

    • {vm|HTMLElement} node
    • {Object} options
      • {Boolean} attachedToDocument
  • Returns:

    • {Wrapper}
  • Usage:

createWrapper creates a Wrapper for a mounted Vue instance, or an HTML element.

import { createWrapper } from '@vue/test-utils'
import Foo from './Foo.vue'

const Constructor = Vue.extend(Foo)
const vm = new Constructor().$mount()
const wrapper = createWrapper(vm)
expect(wrapper.vm.foo).toBe(true)