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.