how to check the actual DOM node using react enzyme

后端 未结 6 488
孤街浪徒
孤街浪徒 2020-12-20 11:29

Is there a way to get the actual DOM node so I can the query it with the Dom api as opposed to being required to use enzyme\'s api, it\'s just for edge cases where for examp

6条回答
  •  猫巷女王i
    2020-12-20 12:03

    You can use soemething like :

    const dialog = component.find(Modal);
    let modal = dialog.node._modal;
    modal.getDialogElement().querySelector('#saveBtn')
    

    based on the test for Modal in react-bootstrap web site

    https://github.com/react-bootstrap/react-bootstrap/blob/master/test/ModalSpec.js

提交回复
热议问题