📜  jest mock react router params - Javascript 代码示例

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

代码示例1
// TeamPage.test.js
jest.mock('react-router-dom', () => ({
  ...jest.requireActual('react-router-dom'), // use actual for all non-hook parts
  useParams: () => ({
    companyId: 'company-id1',
    teamId: 'team-id1',
  }),
  useRouteMatch: () => ({ url: '/company/company-id1/team/team-id1' }),
}));