- VueComponent :
property
- VueFunctionalComponent :
property
- VueTestWrapper :
property
- VueTestWrapperArray :
property
- VueTestErrorWrapper :
property
- Vue :
property
- Wrapper
- vm :
property
- element :
property
- option :
method
- attributes :
method
- attributes :
property
- classes :
method
- classes :
property
- contains :
method
- emitted :
method
- emittedByOrder :
method
- exists :
method
- exist :
property
- find :
method
- findAll :
method
- html :
property
- isSelector :
method
- empty :
property
- visible :
property
- VueInstance :
property
- name :
method
- name :
property
- props :
method
- props :
property
- text :
method
- text :
property
- vm :
- WrapperArray
- wrappers :
property
- length :
property
- wrapperAt :
method
- contains :
method
- isSelector :
method
- empty :
property
- VueInstance :
property
- wrappers :
Type property VueComponent
Check the type of the test subject
- Type:
property
- References:
- Example:
expect(MyComponent).to.be.a.VueComponent
Type property VueFunctionalComponent
Check the type of the test subject
- Type:
property
- References:
- Example:
expect(MyComponent).to.be.a.VueFunctionalComponent
Type property Wrapper
Check the type of the test subject
- Type:
property
- References:
- Example:
expect(MyComponent).to.be.a.VueTestWrapper
Type property WrapperArray
Check the type of the test subject
- Type:
property
- References:
- Example:
expect(wrapper.findAll('div')).to.be.a.VueTestWrapperArray
Type property ErrorWrapper
Check the type of the test subject
- Type:
property
- Example:
expect(wrapper.find('non-existing-tag')).to.be.an.VueTestErrorWrapper
- Type:
property
- References:
- Example:
expect(wrapper.vm).to.be.vue
Access vue-test-util's Wrapper vm
All following chains will operate on the vm object
- Type:
property
- References:
- Example:
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
Access vue-test-util's Wrapper element
All following chains will operate on the root DOM node of the wrapper
- Type:
property
- References:
- Example:
expect(wrapper).to.have.an.element
expect(wrapper).element.to.be.a('HTMLElement')
expect(wrapper).element.to.have.property('innerText')
Access vue-test-util's Wrapper options
- Type:
method
- Params:
- name
string
- val
*
(optional) - msg
string
(optional)
- name
- References:
- Example:
expect(wrapper).to.have.option('attachedToDocument')
Asserts the attributes of the DOM node from the vue-test-util Wrapper
- Type:
method
- Params:
- key
string
name of the attribute - val
*
(optional) - msg
string
(optional)
- key
- References:
- Example:
expect(wrapper).to.have.attributes('id', 'foo')
expect(wrapper).to.have.attributes('id').which.is.a('string').and.equals('foo')
Chain vue-test-utils Wrapper attributes
- Type:
property
- References:
- Example:
expect(wrapper).to.have.attributes.which.has.a.property('id')
expect(wrapper).attributes.to.deep.equal({id: 'foo' })
Assert DOM node classes of the vue-test-util Wrapper
- Type:
method
- Params:
- className
string
|Array.<string>
(optional) - msg
string
(optional)
- className
- References:
- Example:
expect(wrapper).to.have.classes('some-class')
expect(wrapper).to.have.classes(['some-class', 'otherclass'])
Chain vue-test-utils Wrapper's DOM node classes
- Type:
property
- References:
- Example:
expect(wrapper).classes.to.include('some-class')
expect(wrapper).to.have.classes.with.a.lengthOf(2)
Assert vue-test-utils Wrapper contains
- Type:
method
- Params:
- selector
string
|Component
- selector
- References:
- Example:
expect(wrapper).that.contains('div')
expect(wrapper).to.contain('div')
Assert that the wrapped component emitted events
- Type:
method
- Params:
- eventName
string
- times
int
(optional) how often the event should have been emitted - msg
string
(optional)
- eventName
- References:
- Example:
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'})
Assert Wrapper has emitted the following events by order
- Type:
method
- Params:
- events
Array.<string>
|Array.<{name: string, args: Array.<*>}>
- offset
int
(optional) default 0 - msg
string
(optional)
- events
- References:
- Example:
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] }])
Assert that the wrapper exists
- Type:
method
- References:
- Example:
expect(wrapper).to.exists()
Same as method 'exists'
- Type:
property
- References:
- Example:
expect(wrapper).to.exist
Assert that the wrapper has a child matching the given selector which exists
This method is chainable on the found element.
- Type:
method
- Params:
- selector
string
|Component
- msg
string
(optional)
- selector
- References:
- Example:
expect(wrapper).to.find('div')
expect(wrapper).not.to.find('blockquote')
expect(wrapper).to.find('h1').which.has.attributes('id', 'page-heading')
Chain children of Wrapper as WrapperArray
- Type:
method
- Params:
- selector
string
|Component
- msg
string
(optional)
- selector
- References:
- Example:
expect(wrapper).findAll('div').to.be.selector('div')
expect(wrapper).to.findAll('h1').which.has.a.wrapperAt(0).that.is.a.selector('h1')
Chain html of the wrapped DOM node
- Type:
property
- References:
- Example:
expect(wrapper).html.not.to.be.empty
Assert the Wrapper to be/match a selector
- Type:
method
- Params:
- selector
string
- msg
string
(optional)
- selector
- References:
- Example:
expect(wrapper).isSelector('div')
expect(wrapper).to.be.selector(MyComponent)
Assert that the Wrapper does contain child nodes
- Type:
property
- References:
- Example:
expect(wrapper).not.to.be.empty
expect(wrapper).find('input').to.be.empty
Assert the Wrapper is visible
- Type:
property
- References:
- Example:
expect(wrapper).to.be.visible
Assert Wrapper is a Vue instance
- Type:
property
- References:
- Example:
expect(wrapper).to.be.a.VueInstance
expect(wrapper).find('button').not.to.be.a.VueInstance
Assert Wrapper's name
- Type:
method
- Params:
- name
string
- msg
string
(optional)
- name
- References:
- Example:
expect(wrapper).to.have.name('MyComponent')
expect(wrapper).find('.btn').to.have.name('button')
Chain Wrapper's name
- Type:
property
- References:
- Example:
expect(wrapper).name.to.equal('div')
expect(wrapper).name.to.contain('Component')
Assert that wrapper has prop
- Type:
method
- Params:
- key
string
- value
*
(optional) - msg
string
(optional)
- key
- References:
- Example:
expect(wrapper).to.have.props('value', 1)
Chain Wrapper's props
- Type:
property
- References:
- Example:
expect(wrapper).props.to.have.property('value', 1)
expect(wrapper).props.to.deep.equal({value: 1})
Assert text content of Wrapper
- Type:
method
- Params:
- value
string
- msg
string
(optional)
- value
- References:
- Example:
expect(wrapper).to.have.text('the content')
Chain Wrapper's text
- Type:
property
- References:
- Example:
expect(wrapper).text.to.equal('the content')
expect(wrapper).text.to.contain('content')
Chain all wrappers contained in a WrapperArray
- Type:
property
- References:
- Example:
expect(wrapperArr).wrappers.not.to.be.empty
expect(wrapperArr).to.have.wrappers.with.a.lengthOf(2)
Chain Number of Wrappers contained in the WrapperArray
- Type:
property
- References:
- Example:
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)
Assert and chain a Wrapper at index in WrapperArray
- Type:
method
- References:
- Example:
expect(wrapperArr).to.have.a.wrapperAt(0)
expect(wrapperArr).wrapperAt(1).to.be.a.selector('div')
Assert every Wrapper in WrapperArray contains selector
- Type:
method
- Params:
- selector
string
|Component
- selector
- References:
- Example:
expect(wrapperArr).that.contains('div')
expect(wrapperArr).to.contain('div')
Assert every Wrapper's DOM node or vm in WrapperArray to match selector
- Type:
method
- Params:
- selector
string
- msg
string
(optional)
- selector
- References:
- Example:
expect(wrapperArr).isSelector('div')
expect(wrapperArr).to.be.selector(MyComponent)
Assert every Wrapper in WrapperArray does not contain child node
- Type:
property
- References:
- Example:
expect(wrapperArr).not.to.be.empty
expect(otherArr).to.be.empty
Assert every Wrapper in WrapperArray is Vue instance.
- Type:
property
- References:
- Example:
expect(wrapperArr).to.be.a.VueInstance
expect(otherArr).not.to.be.a.VueInstance