如何在 Jest 中从 react-i18next 模拟 Trans 组件

时间:2021-06-16 20:48:54

标签: reactjs jestjs react-i18next

我试图在 Jest 中从 react-i18next 模拟这个 Trans 组件:

<Trans
      i18nKey="orderCards.business.paragraph"
      components={{
        p: <p />,
        strong: <strong />,
        Link: (
          <BusinessAccountLink
            to="/"
            data-testid="business-account-link"
          />
        ),
      }}
    />

It returns this: <p>Text <strong>Bold Text <Link>Click Me</Link></strong></p>
This link is a Link component from react-router-dom

我如何模拟这个组件,以便我可以测试链接是否在点击时有效。

0 个答案:

没有答案