Answers for "useLocation in jest"

0

useLocation in jest

const mockHistoryPush = jest.fn();
jest.mock('react-router-dom', () => ({
    ...jest.requireActual('react-router-dom'),
    useHistory: () => ({
        push: mockHistoryPush,
    }),
    useLocation: () => ({
        pathname: "/"
    })
}));
Posted by: Guest on January-04-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language