react-imgix
react-imgix copied to clipboard
Not able to test an Imgix image with Jest
Describe the bug
I'm trying to write a Jest unit test for one of my components that is rendering an Imgix image. The test is breaking with this error TypeError: Cannot read properties of undefined (reading 'split')
To Reproduce
Run a test that renders an Imgix component render(<Imgix src="https://www.google.com/image-url" htmlAttributes={{ alt: "Image alt" }} />) using @testing-library/react
and then test
await waitFor(() => {
const imgElement = getByAltText("Image alt");
expect(imgElement).toBeInTheDocument();
});
Expected behaviour Expect the test to succeed and image tag to be part of the document when testing.