如何在ReactJ中使用MAP函数编写渲染动态子组件的单元测试(React Testing库)

发布于 2025-02-10 01:37:14 字数 193 浏览 0 评论 0原文

我的数组中有一些问题列表。在该数组中,有问题,选项,类型,ID。 我正在渲染组件并使用地图功能迭代数组。如果数组找到了“无线电”类型,则我在父级和通过道具中渲染另一个组件radiotypecont。同样,如果类型是“ text”,我正在渲染textTypeceponent,...等。 有人可以让我知道如何使用React测试库为此方案编写单元测试吗?

谢谢!

I have a list of questions in my array. Inside that array, there are questions, options, type, id.
I am rendering a component and using map function to iterate the array. If array has found type 'Radio', I'm rendering another component Radiotypecomponent in parent one and passing props. Similarly, if type is "text" I'm rendering Texttypecomponent, ...etc.
Can someone please let me know how to write unit test for this scenario using react testing library?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文