How can I exclude files from Jest watch?

前端 未结 7 1741
眼角桃花
眼角桃花 2021-02-01 12:17

I\'m doing some slightly bizarre stuff using Jest for testing where I\'m writing some stuff to disk. If I use the watch flag in Jest however then I\'m finding (quit

7条回答
  •  情书的邮戳
    2021-02-01 12:58

    I had the same problem when I had a directory that must not be tested, although I still wanted it to be inside of the __tests__ directory (e.g., __mocks__).

    You should not use a use relative paths in such case (no slashes). So inside of your package.json file add:

    jest: {
      "modulePathIgnorePatterns": ["__mocks__"]
    }
    

    That solved my problem.

提交回复
热议问题