2

I'm trying to test my App.js file with React Testing Library When I try to render the App component I always get this error ReferenceError: IntersectionObserver is not defined.

When I went through the code, I saw that the ScrollMenu component from the React horizontal scrolling menu library causes this issue as it only supports the browser level. I think this happens because React Testing Library uses node.js runtime.

What I can do to render and test the App component?

My App component

import { ScrollMenu } from 'react-horizontal-scrolling-menu';

<ScrollMenu>
  {data.map((item) => (
    <ComponentOne data={data} />
  ))}
</ScrollMenu>

My App test file

test('renders the app', () => {
  render(
    <MemoryRouter>
      <App />
    </MemoryRouter>
  );
});
camille
  • 278
  • 1
  • 2
  • 20

0 Answers0