question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

template fails to re-render when ref value is changed under test when using vue@2.7.3

See original GitHub issue

Subject 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:open
  • Created a year ago
  • Reactions:6
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
dneuschaefer-rubecommented, Aug 1, 2022

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 to vue.runtime.mjs, which re-exports from vue.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:

resolve: {
    alias: {
        vue: 'vue/dist/vue.runtime.mjs',
    },
},

While there’s good reason to use the ESM build in production, that should be fine for the test execution.

2reactions
admhprcommented, Jul 11, 2022

likely related #1983

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found