如何解决玩笑单元测试-如何模拟表格行图标的点击事件
我将如何编写玩笑/酶单元测试来模拟行图标的点击处理程序,该处理程序仅在将鼠标悬停在[或]单击表行上时显示。
**code that I tried given below:-**
let wrapper = mount(<TableComponent {...mockData} />);
wrapper.find('.table-row').simulate('click');
wrapper.find('.row-action-icon').simulate('click')
//失败,因为row-action-icon未附加到DOM
有人可以帮助我解决此问题吗?
解决方法
我想出了上述情况的解决方案。它可能会帮助某人
dd=array('f',[[0]*5]*15)
-
类似地,我们可以使用“ @ testing-library / react”;
1) Mocking the component using jest mount. const wrapper = mount(<TableComponent {...mockData} />); 2) Trigger a mounse enter for the table row. wrapper.find('.table__body__row').at(0).props().onMouseEnter(); 3) Update the wrapper. It will intern update the DOM and insert the row icon. wrapper.update(); 4) Finally we can perform the action for the row icon wrapper.find('.row-actions-menu__trigger').simulate('click');
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。