This works for me, I was having problems with useLocation too
jest.mock('react-router-dom', () => ({ useHistory: () => ({ push: jest.fn() }), useLocation: jest.fn().mockReturnValue({ pathname: '/another-route', search: '', hash: '', state: null, key: '5nvxpbdafa'})}))