I'm rendering the below react component, Below is the code. I have defined both params and uselocation but I keep getting this error TypeError: Cannot read properties of undefined (reading 'match'). Does anyone know what's wrong in it?
jest.mock('react-router-dom', () => {
return {
matchPath: jest.fn().mockReturnValue({
isExact: true,
params: {
sId: "aadb37fd-55e3-490b-9aeb-a577416136f7",
subId: "ca7b321b-7544-42e7-bcaf-a5607e49469b",
},
path: "/he/sub/:sId/:subId",
url: "/he/sub/aadb37fd-55e3-490b-9aeb-a577416136f7/ca7b321b-7544-42e7-bcaf-a5607e49469b",
}),
useParams: jest.fn().mockReturnValue({ sId: 'aadb37fd-55e3-490b-9aeb-a577416136f7', subId: "ca7b321b-7544-42e7-bcaf-a5607e49469b" }),
useLocation: jest.fn().mockReturnValue({ sId: 'aadb37fd-55e3-490b-9aeb-a577416136f7', subId: "ca7b321b-7544-42e7-bcaf-a5607e49469b" }),
};
});
describe("Submission Details", () => {
beforeEach(() => {
ReactRedux.useSelector = jest.fn().mockImplementation((callback) => callback(initialState));
ReactRedux.useDispatch = jest.fn().mockImplementation(() => mockDispatch);
});
const initialState = {
router: {
location: {
pathname: "/he/sub/aadb37fd-55e3-490b-9aeb-a577416136f7/ca7b321b-7544-42e7-bcaf-a5607e49469b",
},
},
}
it("renders form details", () => {
let preselectedTab = "form";
render(<SDetails preselectedTab={preselectedTab} />);
})