I'm new to react testing, getting this (ReferenceError: ResizeObserver is not defined) error but i'm not using it anywhere, i think problem is with allotment library example : https://codesandbox.io/s/6bdt88
any idea with this error ?

import React from "react";
import Page from "../Page";
import { Provider } from "react-redux";
import { store } from "../../redux/store";
import "@testing-library/jest-dom/extend-expect";
describe("Testing component Page", () => {
const Navbar = (): RenderResult =>
render(
<Provider store={store}>
<MemoryRouter>
<Page />
</MemoryRouter>
</Provider>
);
test("Testing Page", () => {
Navbar();
});
});
Apprently Allotment library uses 'ResizeObserver' and in your setupTests.js(if you dont have it, just create it) file paste this and it will fix it:
global.ResizeObserver = jest.fn().mockImplementation(() => ({
observe: jest.fn(),
unobserve: jest.fn(),
disconnect: jest.fn(),
}))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With