How to clear Jest cache?

Manuel picture Manuel · Jul 2, 2017 · Viewed 84.6k times · Source

Jest is picking up an old version of a package and thus my tests fail unless I use --no-cache. I can even delete the package folder from node_modules and Jest is happy to run the tests (almost all passing).

So how do I clear Jest cache?

Answer

Ryan H. picture Ryan H. · Oct 12, 2017

As of Jest 22.0.0+, you can use the --clearCache option:

Deletes the Jest cache directory and then exits without running tests. Will delete cacheDirectory if the option is passed, or Jest's default cache directory.

For easy reference (as per @Beraliv): https://facebook.github.io/jest/docs/en/cli.html#clearcache