0.2.0
Add waitForUpdate
The waitForUpdate() helper function can be used to clean up a chain of async DOM assertions that you would normally have to use Vue.nextTick() for.
For example we could rewrite the following test:
const Component = {
template: `<p>{{ message }}</p>`,
props: ['message']
}
it('tests message updates', () => {
const vm = mount(Component, { message: 'Hello' })
expect($(vm.$el)).to.have.text('Hello')
vm.message = 'World'
return vm.$nextTick().then(() => {
expect($(vm.$el)).to.have.text('World')
vm.message = 'VueUnit'
return vm.$nextTick()
}).then(() => {
expect($(vm.$el)).to.have.text('VueUnit')
})
})like so:
it('tests message updates', () => {
const vm = mount(Component, { message: 'Hello' })
expect($(vm.$el)).to.have.text('Hello')
vm.message = 'World'
waitForUpdate(() => {
expect($(vm.$el)).to.have.text('World')
vm.message = 'VueUnit'
}).then(() => {
expect($(vm.$el)).to.have.text('VueUnit')
}).end(done)Please note when using waitForUpdate() use must end your chain of assertions with .end(done) to avoid errors.