Categories
JavaScript Answers

How to clear the Jest cache?

Spread the love

Sometimes, we want to clear the Jest cache.

In this article, we’ll look at how to clear the Jest cache.

How to clear the Jest cache?

To clear the Jest cache, we can run jest with the --clearCache option.

We run

jest --clearCache

to clear the Jest cache.

Or we can put it in a script in package.json with

{
  //  ...
  "scripts:" {
    "clearJest": "jest --clearCache"
  }
  // ...
}

and run npm run clearJest

Conclusion

To clear the Jest cache, we can run jest with the --clearCache option.

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 *