I am testing using jest and am rendering a mock component that contains a useEffect hook, but upon running my tests I'm receiving the error "Too many re-renders. React limits the number of renders to prevent an infinite loop." How do I go about preventing the useEffect to cause a re-render and fail my tests.
Mock component is created like: renderWithReactIntl(<Component {...mockData} />);
I'm trying to do something such as the following to try and call it once but it doesn't seem to be helping
describe("<Component />", () => {
beforeEach(() => {
jest.clearAllMocks();
jest.spyOn(React, "useEffect").mockImplementationOnce(fn => fn());
});