简体   繁体   中英

React Testing Library: How to remove an item from the Semantic UI Dropdown (in Multiple Selection mode)?

Semantic UI Dropdown的DOM代码截图

语义 UI 下拉菜单的屏幕截图

While building my tests, I've come up against an issue for which I can't find a solution. Simply put, I want to remove the "Selects any" option from the Semantic UI Dropdown which I've previously added. I've tried several approaches unsuccessfully to fireEvent.click on the little "X" that appears beside the text but none work. Might anyone have any suggestions?

Did you try accessing to the i tag getting the label of your element? Something like:

fireEvent.click(screen.getByText(/Selects any/).querySelector('i'));

react-testing-library queries return DOM nodes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM