Is accessing `data` properties via `wrapper.vm` the correct way, as per the docs?
It may be possible, but .vm
is the correct way.
Example from the vue-test-utils
documentation:
it('button click should increment the count', () => { expect(wrapper.vm.count).toBe(0) const button = wrapper.find('button') button.trigger('click') // `wrapper.vm.count` it is! expect(wrapper.vm.count).toBe(1)})
Modifying DevLime's answer a bit, I prefer to use wrapper.vm.$data instead of wrapper.vm as follows:
it('button click should increment the count', () => { expect(wrapper.vm.$data.count).toBe(0) const button = wrapper.find('button') button.trigger('click') // `wrapper.vm.$data.count` it is! expect(wrapper.vm.$data.count).toBe(1)})
It works fine with V2 of Vue test utils.