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");- ✓Correct answer:
triggerreturns a promise that resolves after Vue updates the DOM - 2Without
awaitthe click is not dispatched - 3Tests in Vue must always be async
Explanation
DOM updates are asynchronous. Awaiting trigger or setValue (or nextTick) makes assertions see the updated DOM.