I am trying to test disappearance of dialog box when user clicks "cancel" button on my dialog box using the following test:
it("clicking on cancel hides the confirmation dialog", async() => {
render(<ConfirmationDialog />);
const cancelButton = screen.getByText("Cancel");
fireEvent.click(cancelButton);
await waitForElementToBeRemoved(() => screen.queryByText(/Cancel/i));
expect(screen.queryByText(/Cancel/i)).toBeNull();
});
But the above code throws an error : TypeError: MutationObserver is not a constructor
24 | const cancelButton = screen.getByText("Cancel");
25 | fireEvent.click(cancelButton);
> 26 | await waitForElementToBeRemoved(() => screen.queryByText(/Cancel/i));
| ^
27 | expect(screen.queryByText(/Cancel/i)).toBeNull();
28 | });
29 | });
Can someone help me understanding this issue as I am new to testing library. Thanks in advance.