Complete the code to wait for the async function to finish before asserting.
await [1]();You need to await the async function fetchData to ensure it finishes before continuing.
Complete the code to trigger the button click and wait for DOM updates.
await wrapper.find('button').trigger('[1]'); await nextTick();
The event to simulate a button press is click.
Fix the error in the test by correctly waiting for the promise to resolve.
await [1](); expect(wrapper.text()).toContain('Loaded');
flushPromises waits for all pending promises to resolve, ensuring the component updates before assertions.
Fill both blanks to correctly mock an async API call and wait for the component update.
jest.spyOn(api, '[1]').mockResolvedValue({ data: 'test' }); await [2]();
Mock the fetchData API call and then wait for all promises to resolve with flushPromises.
Fill all three blanks to test async data fetching and DOM update in a Vue component.
const wrapper = mount(Component); await wrapper.vm.[1](); await [2](); expect(wrapper.find('p').text()).toBe('[3]');
Call the component method loadData, wait for promises with flushPromises, then check the paragraph text is Hello World.