We can mock the useLocation() by using the following code
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useLocation: () => ({
pathname: 'localhost:3000/examplePath/123',
}),
}));
Discover more from Learners Store
Subscribe to get the latest posts sent to your email.