reactjs - 如何在 Jest 中从 react-i18next 模拟 Trans 组件
问题描述
我试图在 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
我如何模拟这个组件,以便我可以测试单击时链接是否有效。
解决方案
推荐阅读
- python-3.x - 如何使用 tensorflow 2 模型动物园在自定义对象检测器中创建检查点?
- javascript - 将组件的结果传递给渲染返回未定义?
- flexbox - 嵌套在部分类中的 DIV 类未设置为显示:flex
- javascript - 如果未单击任何复选框,则禁用按钮
- android - 找不到模块 node_modules\@react-native-community\cli\build\bin.js'
- reactjs - 如何使用 react-native-firebase/admob 显示 Google 呈现的同意书
- c - Union 的大小以及为什么它会返回 24
- python - SymPy 中 evalf 的错误结果,但仅适用于某些精度值
- android - Android Kotlin 获取选定 Spinner 项的值
- javascript - 如何在集合中创建与唯一授权用户 UID 同名的文档?