Vue · Middle · Question 48 of 75

Why await user interactions in Vue Test Utils?

const wrapper = mount(Counter);
await wrapper.find("button").trigger("click");
expect(wrapper.text()).toContain("1");

Explanation

DOM updates are asynchronous. Awaiting trigger or setValue (or nextTick) makes assertions see the updated DOM.

Further reading

Problem with a question

Vue · Middle · question 48

Test yourself

Take the Vue · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz