template fails to re-render when ref value is changed under test when using vue@2.7.3
See original GitHub issueSubject of the issue
template fails to re-render when ref value is changed under test when using vue@2.7.3
template does update with user interaction in browser.
elements using v-if
directive fail to re-render when predicate value changes during unit testing.
Steps to reproduce
https://codesandbox.io/s/fervent-tdd-fijnxf
run npm run test
Expected behaviour
template is re-rendered and relevant elements found using wrapper.find
/wrapper.findAll
Actual behaviour
no change in template
Possible Solution
?
much appreciated!
Issue Analytics
- State:
- Created a year ago
- Reactions:6
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Vue test utils is updating the component data but not re ...
I ran into very similar problem and solved it with await wrapper.vm.$forceUpdate(); before assertion that failed. This forces Vue to update ...
Read more >Changelog - Kendo UI for Vue
window is undefined error in form; viewHTML window in the Editor can't be closed using the x button; chartSeriesItemTooltip render function warning ...
Read more >Re-render a component when prop changes : r/vuejs - Reddit
I have a component that I'm using Render Functions for to return a custom render that depends on the reactive prop items that...
Read more >Sitemap - Sciter
Calling code behind UI from worker threads. Sciter UI, application architecture. Category: Design · 25 video streams with frame rate 30 each in...
Read more >Changelog - HTML-validate
better error message when failing to parse html-validate directive (0e9d98e), ... rules: no-missing-references handles attributes with reference lists ...
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 FreeTop 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
Top GitHub Comments
I believe this is a case of the dual package hazard that has already caused issues at other places (see e.g. https://github.com/vuejs/vue/issues/12626).
Essentially, the vite plugin for vue2 aliases vue imports to the ESM file (
vue.runtime.esm.js
), while imports through VTU go tovue.runtime.mjs
, which re-exports fromvue.runtime.common.js
. That means that watchers imported from other files (e.g. through composables) or the watcher to re-render the template are set up on a the wrong Vue instance, and thus don’t trigger as expected.Unfortunately I’m not sure what the “proper” workaround for that is; I could see the root issue being with the vite plugin, the way VTU imports Vue, or even with the exports declaration from the vue package. Maybe someone else has a better understanding there.
What does work as a temporary fix though is to override the resolve alias defined through the vite plugin in your test config:
While there’s good reason to use the ESM build in production, that should be fine for the test execution.
likely related #1983