编写测试用例时,无法获取Mui-datagrid Usi jest框架

发布于 2025-02-13 19:59:46 字数 185 浏览 0 评论 0原文

我的react应用程序中有一个mui-datagrid。在datagrid中,一些带有标头的数据('csa name','start date')。我想在jest.used'getallbyrole('cell',{description: /csa name /i})中编写测试用例时,选择“ CSA名称”列中的所有项目',

但它不起作用。

I have a mui-datagrid in my react application.In the datagrid, some data with the headers ('CSA NAME', 'START DATE'). I would like to select all items in column 'CSA NAME' while writing test case in jest.used 'getAllByRole('cell', { description: /CSA NAME/i })'

but it's not working.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执妄 2025-02-20 19:59:46

如果要单击“选择所有项目”的复选框,则可以尝试使用类似的内容:

const tableCheckBoxes = screen.getAllByRole('checkbox', {name: '...'});
// you can set aria-label attribute to each checkbox for accessibility improvements and then get checkboxes by role and name additionally

userEvent.click(tableCheckBoxes[0]); 
// where tableCheckBoxes[0] is your select all checkbox

如果页面上只有表复选框,则应使用此类内容。

If you want to click to checkbox for select all items you could try to use something like this:

const tableCheckBoxes = screen.getAllByRole('checkbox', {name: '...'});
// you can set aria-label attribute to each checkbox for accessibility improvements and then get checkboxes by role and name additionally

userEvent.click(tableCheckBoxes[0]); 
// where tableCheckBoxes[0] is your select all checkbox

It should work in case if you have only table checkboxes on the page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文