Open wisnuvb opened 2 years ago
I had the same error, found solution in src/utils/intersection-observer.spec.js: Adding
window.IntersectionObserver = {};
window.IntersectionObserverEntry = {
prototype: {
isIntersecting: () => null,
},
};
at the beginning of your test or in setupTests fixes the problem.
@wisnuvb one other idea is that you can actually mock it in your setupTests
.
jest.mock("react-lazy-load-image-component", () => ({
LazyLoadImage: ({ src, alt }) => <img alt={alt} src={src} />
}));
I run the test (RTL) getting error
TypeError: Cannot read properties of undefined (reading 'prototype')
while rendering component.I've tried looking everywhere but can't find a solution. I post here to get enlightenment on how to test this component. The screenshot above shows that I immediately called the component, although not directly, the result was still an error. Thanks 🙏