Categories
JavaScript Answers

How to exclude files from Jest watch with JavaScript?

Spread the love

Sometimes, we want to exclude files from Jest watch with JavaScript.

In this article, we’ll look at how to exclude files from Jest watch with JavaScript.

How to exclude files from Jest watch with JavaScript?

To exclude files from Jest watch with JavaScript, we can add the modulePathIgnorePatterns property into our Jest config.

For instance, in our Jest config, we add

{
  //...
  "modulePathIgnorePatterns": ["directoryNameToIgnore"]
  //...
}

to set the modulePathIgnorePatterns property in our Jest config to an array that has strings of the directories to ignore when running Jest tests.

Conclusion

To exclude files from Jest watch with JavaScript, we can add the modulePathIgnorePatterns property into our Jest config.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *