-
Notifications
You must be signed in to change notification settings - Fork 665
Closed
Labels
Description
Version
1.0.0-beta.30
Reproduction link
https://i-included-a-repro.com
Steps to reproduce
repro
import { mount, shallowMount } from '@vue/test-utils'
const Comp = {
template: '<div />',
props: ['myProp'],
watch: {
myProp: {
handler(val, oldVal) {
console.log('Original watcher triggered!')
},
deep: true
}
}
}
test('Both watchers trigger', (done) => {
const wrapper = mount(Comp, {
propsData: {
myProp: 'foo'
},
watch: {
myProp: {
handler(val, oldVal) {
console.log('Overridden watcher triggered!')
},
deep: true
}
}
})
wrapper.setProps({ myProp: 'ok' })
setTimeout(() => {
done()
}, 100)
})
What is expected?
Only the mounting options watcher should do anything.
What is actually happening?
Both watchers are triggered.
This is because of this line here which uses Vue's watcher merge strategy, which is to create an array of watchers. That code is in Vue core, found here.