Jest clear cache

When your Jest tests used to pass but suddenly started to fail, this may be related to cache.

In my case, the test coverage was reporting uncovered lines. When I cleared my Jest cache, the tests passed again.

To clear cache with Yarn:

$ yarn jest --clearCache
yarn run v1.9.4
$ ./node_modules/.bin/jest --clearCache
Cleared /var/folders/c8/hg7gtddj49qgpvghtv2grkp9j21wxz/T/jest_r86htr
✨  Done in 0.54s.

Or with npx:

$ npx jest --clearCache

If you enjoyed this post, please consider supporting this site!