I'm trying to test a React component that should download a file and display an alert when a link is clicked. I'm using Jest and React-testing-library for my tests, but I'm running into an error message.
Here's the code for my test:
test('clicking the link should download a file and display an alert', async () => {
const { getByRole } = render(<MyComponent />);
const link = getByRole('link');
await fireEvent.click(link);
expect(within(screen.getByRole('alert')).getByText(/File downloaded/i)).toBeInTheDocument()
});
When I run this test, I get the following error message:
Error: Not implemented: navigation (except hash changes)
The test works but I would like to get rid of the warning message.
I tried every solution proposed in this post: How to fix Error: Not implemented: navigation (except hash changes)
Thank you in advance for your help.