Skip to content

fix: wait for the next tick #1387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 3, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,15 @@ Create a file in `src` named `Counter.vue`:
And create a test file named `test/Counter.spec.js` with the following code:

```js
import Vue from 'vue';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! Prettier is complaining about this semicolon. yarn run format will fix it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also use wrapper.vm.$nextTick(), but this could be a bit more future proof, as nextTick will no longer be avail on the vm in V3...

import { shallowMount } from '@vue/test-utils'
import Counter from '../src/Counter.vue'

describe('Counter.vue', () => {
it('increments count when button is clicked', () => {
it('increments count when button is clicked', async () => {
const wrapper = shallowMount(Counter)
wrapper.find('button').trigger('click')
await Vue.nextTick()
expect(wrapper.find('div').text()).toMatch('1')
})
})
Expand Down