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

后端 未结 5 1095
别跟我提以往
别跟我提以往 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:55

    If you don't already have jest-dom installed, you need to install it using the command below.

    npm i --save-dev @testing-library/jest-dom
    

    create a file in the root of your project folder and name it jest-setup.js. Your file should have the following content.

    import "@testing-library/jest-dom/extend-expect";
    

    In your package.json, add the code below to your jest config;

    "jest": {
        "setupFilesAfterEnv": ["/jest-setup.js"]
    }
    

提交回复
热议问题