react-testing-library why is toBeInTheDocument() not a function

后端 未结 5 1097
别跟我提以往
别跟我提以往 2021-02-11 15:35

Here is my code for a tooltip that toggles the CSS property display: block on MouseOver and on Mouse Out display: none.

 it(\'should sho         


        
5条回答
  •  别跟我提以往
    2021-02-11 15:56

    Instead of doing:

        expect(queryByText('test')).toBeInTheDocument()
    

    you can find and test that it is in the document with just one line by using

        let element = getByText('test');
    

    The test will fail if the element isn't found with the getBy call.

提交回复
热议问题