0

我正在使用react-dom/test-utils来测试我的组件。我想测试对表行的删除操作。单击删除按钮后,应出现一个模式,并且必须单击确认按钮才能完成删除操作。

这是我模拟删除图标单击的代码,但是在下一行中,不确定模式是否已经出现,并且找不到确认按钮。

act(() => {
      ReactDOM.render(
        <TableScreen />, container,
      )
    })

    Simulate.click(document.querySelector('td path')) // click on delete icon
    Simulate.click(document.getElementsByClassName('btn btn-primary')[2]) // trying to click the confirm button (throws error)
    
// expect that the delete method got called 

错误消息类似于:TypeError: Cannot read property '__reactFiber$iq4owli49h' of undefined

4

0 回答 0