Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Latest commit

 

History

History
600 lines (477 loc) · 17 KB

API.md

File metadata and controls

600 lines (477 loc) · 17 KB

Index


VueComponent property

Type property VueComponent

Check the type of the test subject

expect(MyComponent).to.be.a.VueComponent

VueFunctionalComponent property

Type property VueFunctionalComponent

Check the type of the test subject

expect(MyComponent).to.be.a.VueFunctionalComponent

VueTestWrapper property

Type property Wrapper

Check the type of the test subject

expect(MyComponent).to.be.a.VueTestWrapper

VueTestWrapperArray property

Type property WrapperArray

Check the type of the test subject

expect(wrapper.findAll('div')).to.be.a.VueTestWrapperArray

VueTestErrorWrapper property

Type property ErrorWrapper

Check the type of the test subject

  • Type: property
  • Example:
expect(wrapper.find('non-existing-tag')).to.be.an.VueTestErrorWrapper

Vue property

expect(wrapper.vm).to.be.vue

vm property, Wrapper

Access vue-test-util's Wrapper vm

All following chains will operate on the vm object

expect(wrapper).to.have.vm
expect(wrapper).to.have.vm.which.has.a.property('$data')
expect(wrapper).vm.to.have.property('$data')
expect(wrapper).vm.to.be.empty

element property, Wrapper

Access vue-test-util's Wrapper element

All following chains will operate on the root DOM node of the wrapper

expect(wrapper).to.have.an.element
expect(wrapper).element.to.be.a('HTMLElement')
expect(wrapper).element.to.have.property('innerText')

option method, Wrapper

Access vue-test-util's Wrapper options

expect(wrapper).to.have.option('attachedToDocument')

attributes method, Wrapper

Asserts the attributes of the DOM node from the vue-test-util Wrapper

expect(wrapper).to.have.attributes('id', 'foo')
expect(wrapper).to.have.attributes('id').which.is.a('string').and.equals('foo')

attributes property, Wrapper

Chain vue-test-utils Wrapper attributes

expect(wrapper).to.have.attributes.which.has.a.property('id')
expect(wrapper).attributes.to.deep.equal({id: 'foo' })

classes method, Wrapper

Assert DOM node classes of the vue-test-util Wrapper

expect(wrapper).to.have.classes('some-class')
expect(wrapper).to.have.classes(['some-class', 'otherclass'])

classes property, Wrapper

Chain vue-test-utils Wrapper's DOM node classes

expect(wrapper).classes.to.include('some-class')
expect(wrapper).to.have.classes.with.a.lengthOf(2)

contains method, Wrapper

Assert vue-test-utils Wrapper contains

expect(wrapper).that.contains('div')
expect(wrapper).to.contain('div')

emitted method, Wrapper

Assert that the wrapped component emitted events

expect(wrapper).to.have.emitted('change')
expect(wrapper).not.to.have.emitted('change')
expect(wrapper).to.have.emitted('click', 7)
expect(wrapper).to.have.emitted('change').which.deep.contains({value: 'newValue'})

emittedByOrder method, Wrapper

Assert Wrapper has emitted the following events by order

expect(wrapper).to.have.emittedByOrder(['ready', 'change', 'destroyed'])
expect(wrapper).to.have.emittedByOrder(['change', 'destroyed'], 1)
expect(wrapper).to.have.emittedByOrder([{ name: 'change', args: [4] }])

exists method, Wrapper

Assert that the wrapper exists

expect(wrapper).to.exists()

exist property, Wrapper

Same as method 'exists'

expect(wrapper).to.exist

find method, Wrapper

Assert that the wrapper has a child matching the given selector which exists

This method is chainable on the found element.

expect(wrapper).to.find('div')
expect(wrapper).not.to.find('blockquote')
expect(wrapper).to.find('h1').which.has.attributes('id', 'page-heading')

findAll method, Wrapper

Chain children of Wrapper as WrapperArray

expect(wrapper).findAll('div').to.be.selector('div')
expect(wrapper).to.findAll('h1').which.has.a.wrapperAt(0).that.is.a.selector('h1')

html property, Wrapper

Chain html of the wrapped DOM node

expect(wrapper).html.not.to.be.empty

isSelector method, Wrapper

Assert the Wrapper to be/match a selector

expect(wrapper).isSelector('div')
expect(wrapper).to.be.selector(MyComponent)

empty property, Wrapper

Assert that the Wrapper does contain child nodes

expect(wrapper).not.to.be.empty
expect(wrapper).find('input').to.be.empty

visible property, Wrapper

Assert the Wrapper is visible

expect(wrapper).to.be.visible

VueInstance property, Wrapper

Assert Wrapper is a Vue instance

expect(wrapper).to.be.a.VueInstance
expect(wrapper).find('button').not.to.be.a.VueInstance

name method, Wrapper

Assert Wrapper's name

expect(wrapper).to.have.name('MyComponent')
expect(wrapper).find('.btn').to.have.name('button')

name property, Wrapper

Chain Wrapper's name

expect(wrapper).name.to.equal('div')
expect(wrapper).name.to.contain('Component')

props method, Wrapper

Assert that wrapper has prop

expect(wrapper).to.have.props('value', 1)

props property, Wrapper

Chain Wrapper's props

expect(wrapper).props.to.have.property('value', 1)
expect(wrapper).props.to.deep.equal({value: 1})

text method, Wrapper

Assert text content of Wrapper

expect(wrapper).to.have.text('the content')

text property, Wrapper

Chain Wrapper's text

expect(wrapper).text.to.equal('the content')
expect(wrapper).text.to.contain('content')

wrappers property, WrapperArray

Chain all wrappers contained in a WrapperArray

expect(wrapperArr).wrappers.not.to.be.empty
expect(wrapperArr).to.have.wrappers.with.a.lengthOf(2)

length property, WrapperArray

Chain Number of Wrappers contained in the WrapperArray

expect(wrapperArr).wrappers.length.to.be.at.least(2)
expect(wrapperArr).wrappers.to.have.a.lengthOf(2)
expect(wrapperArr).length.to.be.at.least(2)
expect(wrapperArr).to.have.a.lengthOf(2)

wrapperAt method, WrapperArray

Assert and chain a Wrapper at index in WrapperArray

expect(wrapperArr).to.have.a.wrapperAt(0)
expect(wrapperArr).wrapperAt(1).to.be.a.selector('div')

contains method, WrapperArray

Assert every Wrapper in WrapperArray contains selector

expect(wrapperArr).that.contains('div')
expect(wrapperArr).to.contain('div')

isSelector method, WrapperArray

Assert every Wrapper's DOM node or vm in WrapperArray to match selector

expect(wrapperArr).isSelector('div')
expect(wrapperArr).to.be.selector(MyComponent)

empty property, WrapperArray

Assert every Wrapper in WrapperArray does not contain child node

expect(wrapperArr).not.to.be.empty
expect(otherArr).to.be.empty

VueInstance property, WrapperArray

Assert every Wrapper in WrapperArray is Vue instance.

expect(wrapperArr).to.be.a.VueInstance
expect(otherArr).not.to.be.a.VueInstance