Wrapper.vm vs wrapper

Hi All,

I am new to unit-testing in Vue. I learnt that vue-test-utils is basically a wrapper based API.
I am now confused so as when to use methods of wrapper.vm and that of wrapper. Both seem to expose same methods I guess. Though I am aware that wrapper.vm is the actual Vue instance. I want to understand what is right and what is wrong

Please correct me if I am wrong.


You’ll use wrapper.vm when you need to access the Vue instance, such as calling methods or accessing any instance properties ($data, $el, etc.).

It’s true that wrapper exposes some functions to access these as well, e.g. getting prop data, but these are mainly just syntax sugars (afaik).

For example, setValue on an input, is syntax sugar for

textInput.element.value = value

I suppose you could say that wrapper is the manager of the component being tested, whereas wrapper.vm is the actual component.