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.
is
Deprecation warning
Using is
to assert that wrapper matches DOM selector is deprecated and will be removed.
For such use cases consider a custom matcher such as those provided in jest-dom.
or for DOM element type assertion use native Element.tagName
instead.
To keep these tests, a valid replacement for:
is('DOM_SELECTOR')
is an assertion ofwrapper.element.tagName
.is('ATTR_NAME')
is a truthy assertion ofwrapper.attributes('ATTR_NAME')
.is('CLASS_NAME')
is a truthy assertion ofwrapper.classes('CLASS_NAME')
.
Assertion against component definition is not deprecated
When using with findComponent, access the DOM element with findComponent(Comp).element
Assert Wrapper
DOM node or vm
matches selector.
Arguments:
{string|Component} selector
Returns:
{boolean}
Example:
import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'
const wrapper = mount(Foo)
expect(wrapper.is('div')).toBe(true)