Skip to content

Guides

How to cache Jest transforms

Jest re-transforms every file on every run.

4 min read

Jest re-transforms every file on every run.

Why it happens

The transform cache directory is not persisted between jobs.

How to fix it

  1. Set --cacheDirectory to a stable path and cache it
  2. Key on the lockfile and the Babel or SWC config
  3. Switch the transformer to SWC or esbuild — usually a bigger win than the cache

Your next build could be twice as fast, at half the price

Start free. Migrating away is the same one line, and we publish that diff too.