setProps does not update a data property
See original GitHub issueVersion
1.0.0-beta.11
Reproduction link
https://github.com/iraklisg/vue-test-utils-example
Steps to reproduce
- Clone the repo
npm install
npm run test
ornpm run watch
What is expected?
The test should pass
What is actually happening?
The setProps
method does not update the data property
If we mount the component with options (propsData
), instead of using the setProps()
method, the test will pass green
wrapper = mount(Foo, {
propsData: {
dataFoo: "foo"
}
});
<!-- generated by vue-issues. DO NOT REMOVE -->
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
this.setProps doesnt automatically update - Stack Overflow
The property updates after the function ends and next time I called my function myProperty is the new value but does anyone know...
Read more >setProps - Vue Test Utils
Sets Wrapper vm props and forces update. WARNING. setProps should be called only for top-level component, mounted by mount or shallowMount.
Read more >setProps(nextProps) · Enzyme - GitHub Pages
A method that sets the props of the root component, and re-renders. Useful for when you are wanting to test how the component...
Read more >[Solved]-How do I use @vue/test-utils to setProps and have them ...
Your component is not expecting any props. When you mounting your component you are setting component's data property. And if you want to...
Read more >Update Props | Testing Library
This is an example of how to update the props of a rendered component. ... same component on the same container does not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@iraklisg, Using
setProps()
does not re-instantiate the component/vm/wrapper. Instead, it’s similar to when the component’s parent (component or app) modifies the prop value and triggers an update. Update from the documentation appears to be referring to the normal reactivity in Vue.setProps
is found here: https://github.com/vuejs/vue-test-utils/blob/dev/packages/test-utils/src/wrapper.js#L495forces update might be better worded though. I don’t see
$forceUpdate
being called.hey, after many hours of looking, I got an answer of how to workaround this. https://stackoverflow.com/a/66029922/12237505