Skip to content

Latest commit

 

History

History
42 lines (27 loc) · 812 Bytes

find.md

File metadata and controls

42 lines (27 loc) · 812 Bytes

find

::: warning Using find to search for a Component is deprecated and will be removed. Use findComponent instead. :::

Returns Wrapper of first DOM node or Vue component matching selector.

Use any valid DOM selector (uses querySelector syntax).

  • Arguments:

    • {string} selector
  • Returns: {Wrapper}

  • Example:

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

const wrapper = mount(Foo)

const div = wrapper.find('div')
expect(div.exists()).toBe(true)

const byId = wrapper.find('#bar')
expect(byId.element.id).toBe('bar')
  • Note:

    • You may chain find calls together:
const button = wrapper.find({ ref: 'testButton' })
expect(button.find('.icon').exists()).toBe(true)

See also: get.