I am using UseHistory hook in react router v5.1.2 with typescript? When running unit test, I have got issue.
TypeError: Cannot read property \'history
I needed the same when shallowing a react functional component that uses useHistory.
useHistory
Solved with the following mock in my test file:
jest.mock('react-router-dom', () => ({ useHistory: () => ({ push: jest.fn(), }), }));