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.

get

Deprecation warning

Using get to search for a Component is deprecated and will be removed. Use getComponent instead.

Works just like find but will throw an error if nothing matching the given selector is found. You should use find when searching for an element that may not exist. You should use this method when getting an element that should exist and it will provide a nice error message if that is not the case.

import { mount } from '@vue/test-utils'

const wrapper = mount(Foo)

// similar to `wrapper.find`.
// `get` will throw an error if an element is not found. `find` will do nothing.
expect(wrapper.get('.does-exist'))

expect(() => wrapper.get('.does-not-exist'))
  .to.throw()
  .with.property(
    'message',
    'Unable to find .does-not-exist within: <div>the actual DOM here...</div>'
  )