-
Notifications
You must be signed in to change notification settings - Fork 668
Unexpected behaviour when watching #502
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 is a bug caused by dependencies running in the incorrect order. I've created a fix that will be released in the next version. For the moment, you will need to set it('updates computed properties', (done) => {
const wrapper = shallow(App, {
sync: false
})
Vue.nextTick(() => {
expect(wrapper.vm.basket).toEqual(['foo']) // Fails
done()
})
}) Alternatively, you can use beta.12. |
Thanks for the quick response, Edd. I ran your solution locally and though it fixes the original reproduction repository's test, my own tests were still failing. I've pushed an update to the reproduction repository with a bit more code which causes it to fail again. Namely, showing the content conditionally on a user click, then attaching the test component to the document with (For context, I'm testing a searchable dropdown component, so the test above mimics this behaviour). What this seems to do is trigger the watcher once on click, before the |
Should I open a new issue? Or is the second scenario something that falls outside the use-case and won't be fixed? |
This should be fixed in #510 |
Tested this today with my actual suite and its components, which are far more complex than the examples above and everything worked as expected. Thanks for your effort! |
Version
1.0.0-beta.13
Reproduction link
https://github.com/tbuteler/vue-test-utils-issue
Steps to reproduce
Clone the repository, then run:
What is expected?
Component:
Test:
In the
text
watch handler, I expected the computed property to have been updated to the latest value oftext
.What is actually happening?
The computed property is somehow lagging behind. Curiously, this only happens when the computed property is actually being rendered inside the template, otherwise it behaves as expected.
This issue was not present in 1.0.0-beta.12, regardless of what the template contains. From the release information, I would suspect it has something to do with the new
sync
functionality.The text was updated successfully, but these errors were encountered: