Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 678 Bytes

createStub.md

File metadata and controls

31 lines (23 loc) · 678 Bytes

createStub()

  • Arguments:

    • {String} name
  • Returns:

    • {Component}
  • Usage:

Creates a stub component. Useful when combined with find and findAll.

import { shallowMount, createStub } from '@vue/test-utils'
import ComponentWithChild from './ComponentWithChild.vue'

describe('ComponentWithChild', () => {
  it('renders a child component', () => {
    const Child = createStub('Child')
    const wrapper = shallowMount(ComponentWithChild, {
      stubs: {
        Child: Child
      }
    })
    expect(wrapper.findAll(Child).length).toBe(1)
  })
})

Where Child is a component with name: 'Child'.