Where Does Jest Store Its Cache?
Jest caches its dependency map in a temp directory per user. Finding it with --showConfig, clearing it, and the cacheDirectory option.
Last updated
Jest scans your dependency tree once, then caches the map so later runs skip the filesystem churn. That cache lives in the OS temp directory under a per-user jest folder. It is invisible during normal use, which is why disk-full mysteries on CI sometimes trace back here.
Never guess the path. Run jest --showConfig and read cacheDirectory for the exact value on your machine. Clear it with jest --clearCache, which exits without running tests. Pin the cacheDirectory key in config when temp gets wiped between runs or shared runners need a stable spot.
Where Jest stores this, by platform
%TEMP%\jest_*
Per-user temp folder with a jest prefix. Confirm with jest --showConfig. Set cacheDirectory in Jest config to redirect it onto a roomier drive.
/tmp/jest_*
Same temp-based default. macOS may purge /tmp on reboot, costing you one slow first run. --clearCache is the tidy way to force a rebuild.
/tmp/jest_*
Mirrors macOS. Containers with tiny /tmp mounts should set cacheDirectory to a persistent volume, or every run pays the full scan cost.
Frequently asked questions
How do I find Jest's actual cache directory?
Run jest --showConfig and look at the cacheDirectory value. That reflects your config, environment and platform. Don't trust documentation defaults alone since the option is widely overridden.
How do I clear the Jest cache?
Run jest --clearCache. It deletes the cache directory and exits without running tests. Reach for it after upgrades, module renames, or haste-map collisions that survive everything else.
Notice an outdated path? Let us know.