1 import * as reactRouterDomModule from 'react-router-dom';
3 // A simple workaround for jest issue not solved yet
4 // https://stackoverflow.com/questions/67872622/jest-spyon-not-working-on-index-file-cannot-redefine-property
5 jest.mock('react-router-dom', () => {
8 ...jest.requireActual('react-router-dom'),
12 export const mockUseHistory = (value?: Partial<ReturnType<typeof reactRouterDomModule.useHistory>>) => {
13 const mockedUseHistory = jest.spyOn(reactRouterDomModule, 'useHistory');
15 mockedUseHistory.mockReturnValue({
31 createHref: jest.fn(),
35 return mockedUseHistory;