Vue-test-utils: setProps doesn't update watchers

Created on 28 Dec 2017  路  4Comments  路  Source: vuejs/vue-test-utils

I actually still have some issues where one watcher should update another field. Version 1.0.0-beta.9.

props: {
   name: String,
},
data: {
  fullname: ''
},
watch: {
       name(val) {
           this.fullname = val + ' surname';
        },
 }

...
...
wrapper.setProps({
  name: 'new name'
})
wrapper.vm.fullname = 'old name surname';
// however, after calling wrapper.update() it got updated, but not rerendered. And again, after second wrapper.update() it is rendered. I have transition-group element in my code, but it is stubbed

bug

Most helpful comment

All 4 comments

I think the problem is that in the current implementation, watchers are run after the _render() call:

https://github.com/vuejs/vue-test-utils/commit/e4151b00ed72da134b8e6f38239824c87c715ce3#diff-dbfd1670fb2dd50be051adb6643c8c24R18

Usually all watchers would run before the component re-renders.

@vladferix can you post a full reproduction? I'm unable to reproduce using the code you posted

@eddyerburgh okay, here it is
vue-test-utils-bug.zip

Was this page helpful?
0 / 5 - 0 ratings