📜  useLocation in jest - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:29.503000             🧑  作者: Mango

代码示例1
const mockHistoryPush = jest.fn();
jest.mock('react-router-dom', () => ({
    ...jest.requireActual('react-router-dom'),
    useHistory: () => ({
        push: mockHistoryPush,
    }),
    useLocation: () => ({
        pathname: "/"
    })
}));