在我的React.js代码中,我有以下内容:
<span
onClick={addToList}
className='ms-2 pt-2'
title='Adding a new row.'
data-testid='t-editableListItem-add'>
<BsFilePlus size={25} role='button' />
</span>
在单元测试中,可以点击span
:
await userEvent.click(screen.getByTestId('t-editableListItem-add'));
但是在Cypress(13.6.4)中,我不能做同样的事情:
cy.findByTestId('t-editableListItem-add').click();
或
cy.findByTestId('t-editableListItem-add').findByRole('button').click();
neither of them w或ks.
I've even tried the realClick()
from https://github.com/dmtrKovalenko/cypress-real-events but it didn't help.
你知道我做错了什么吗?