react-imgix icon indicating copy to clipboard operation
react-imgix copied to clipboard

Not able to test an Imgix image with Jest

Open reemobeid17 opened this issue 2 years ago • 0 comments

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.

reemobeid17 avatar Sep 18 '23 23:09 reemobeid17