Suppose I have a vue component which emits an event when ready (AG Grid for example):
<ag-grid-vue
...
@grid-ready="onGridReady"
...
/>
how can I wait for this event to be emitted while testing this component with vue-test-utils?
it("should mount correctly", async () => {
const wrapper = mount(AgGridVue);
// ...wait for event to be emitted...
});
For now, I got this working with the following helper method which can be awaited. It checks for the wrapper to have emitted a specified event. When emitted, it resolves the returned promise, otherwise it waits a short while and tries again:
The test can use this utility method to wait for the emit, before continuing the test