-
Notifications
You must be signed in to change notification settings - Fork 668
setData has no effect starting with version 1.0.0-beta-30 #1447
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
Comments
This fixes it for you, its because this requires the template to re-render, on next tick :) test('If logged in, show Logout button.', async () => {
const wrapper = mount(AppHeader)
wrapper.setData({ loggedIn: true })
await wrapper.vm.$nextTick()
expect(wrapper.find('button').isVisible()).toBe(true)
}) |
Thank you for your quick response! Is this going to be the standard behaviour in vue-test-utils? Did I miss some documentation? Could you please point me to the place, where I can read about that? |
https://vue-test-utils.vuejs.org/guides/#using-nexttick We will make this process easier in the next version of VTU. |
Wow - you are really quick! Thank you so much! |
Need to ask once more: It was not the case with beta.29 that async/await was necessary. What was the reason to change that behaviour? |
Version
1.0.0-beta.31
Reproduction link
https://github.com/rowild/vue-unit-testing
Steps to reproduce
Please checkout the repo, which contains 2 simple tests, and run the tests like this:
The second test, which uses
setData()
, fails. Same thing with beta.30.Please continue with:
Now both tests work fine.
What is expected?
Both tests in the example repo should work.
What is actually happening?
Starting with 1.0.0-beta.30 the test that uses "setData()" does not work anymore.
This is a test example that is explained in the Vuemastery "Unit testing" course (link in the readme of the repository), which is, why I assume it is the correct way of writing a test.
The text was updated successfully, but these errors were encountered: