-
Notifications
You must be signed in to change notification settings - Fork 669
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
setProps doesn't update props in some circumstances #738
Comments
This provides more flexibility in using the components compared to accessing the `$parent` component directly. This is particularly relevant because newer versions of `@vue/test-utils` broke how we were injecting the parent components in unit testing. Note: This also updates `@vue/test-utils`, but not to the latest version because there is a bug since `beta-18` causing props not to be updated. This may (or may not) be related to the following issue: vuejs/vue-test-utils#738
This provides more flexibility in using the components compared to accessing the `$parent` component directly. This is particularly relevant because newer versions of `@vue/test-utils` broke how we were injecting the parent components in unit testing. Note: This also updates `@vue/test-utils`, but not to the latest version because there is a bug since `beta-18` causing props not to be updated. This may (or may not) be related to the following issue: vuejs/vue-test-utils#738
This provides more flexibility in using the components compared to accessing the `$parent` component directly. This is particularly relevant because newer versions of `@vue/test-utils` broke how we were injecting the parent components in unit testing. Note: This also updates `@vue/test-utils`, but not to the latest version because there is a bug since `beta-18` causing props not to be updated. This may (or may not) be related to the following issue: vuejs/vue-test-utils#738
Sorry, this is another problem with how we've implemented synchronous renders. There's a PR open to fix this by adding an async option to Vue—vuejs/vue#8240. For the moment, the workaround is to set the test('use Vue.nextTick', (done) => {
const wrapper = mount(TestComponent, { sync: false })
wrapper.trigger('click')
Vue.nextTick(() => {
expect(wrapper.text()).toBe('updated')
done()
})
}) |
Setting sync false and waiting for Vue.nextTick doesn't appear to work around the It does workaround the DOM not updating when |
@TheCycoONE @eddyerburgh |
@HcySunYang I am on vue 2.5.16 |
@TheCycoONE I'm hitting this too. What are you doing as a workaround? |
Unfortunately I haven't found a workaround yet. For now I'm .skipping those tests. |
I guess |
It's hard to pin this bug down. I finally found a minimal failing test: updating a prop that is referenced through a chain of computed and lifecycle hook. I created #820 with that test case. With that specific configuration, here's the table:
I think that table changes slightly depending on the exact component configuration, but that's what I found for the minimal test case. |
Thanks @agriffis . This will be fixed when Vue 2.6 is released. Until then, you will need to run tests with |
FWIW sync = false and Vue.nextTick/setTimeout doesn't seem to work for my use case either :( |
Hello, I have this bug on Vue 2.6.11. When using |
Noticed the same with |
In my testing I have noticed it works mostly after I await |
I think |
setProps returns nextTick if I am not mistaking :/ |
|
Version
1.0.0-beta.19
Reproduction link
https://codesandbox.io/s/1k6y65wp4
Steps to reproduce
Create a component, like the one in the above reproduction, with multiple properties that are watched.
It is important that the watch function reads one of the properties (i.e. if you remove that switch statement from my test case the problem doesn't happen.)
Create a test for that component, call setProps on the property that is read in the watch.
What is expected?
The property should be updated, the component should react to the updated property
What is actually happening?
The property is never updated. props() shows the old value.
Note: this is a regression, it worked correctly in 1.0.0-beta.16 (I did not try other versions)
The text was updated successfully, but these errors were encountered: