获取 * Allby * Testing-Library查询的项目数量
我熟悉的断言期望(element)。 我想测试表中的新行添加,
我可以在文档中主张一些特定项目的文本,
但是这种情况使我认为能够获得testing-library
的findallby*查询的项目数量可能是有益的。
我在测试图书馆中查找了答案,但似乎没有简单的方法来检查Findallby*找到了多少个项目...
任何想法和建议都将受到赞赏
I'm familiar with the assertion of expect(element).toHaveLength(number)
,
I want to test for a new row addition in a table,
I could just assert some specific item's text to be in the document,
But the situation brought me to think it could be beneficial to be able to get the number of items found by testing-library
's findAllby* queries.
I looked in the testing-library docs for an answer but it seems there is no easy way to check how many items were found by findAllby*...
Any ideas and suggestions will be appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以断言
findAllby*
请求结果之类的结果:react-testing-library的
*all*
查询返回阵列: https://testing-library.com/docs/queries/queries/about#types-of--ques-of-queriesYou can assert on the length of
findAllBy*
request results like so :React-testing-library's
*All*
queries return arrays : https://testing-library.com/docs/queries/about#types-of-queries