Running Jest?

Jest suite slow or refusing to load your ESM modules? We clear the backlog.

Jest ran clean for years on CommonJS, then half of npm switched to ESM and the config stopped making sense. We settle the transformer, prune the snapshots, and get your test run back to something that finishes before lunch.

  • Since 2015Fixing technology
  • FreeEstimates
  • US teamReal engineers

jest-run.log

still failing

What it is

Jest at a glance

Jest is a JavaScript testing framework built at Facebook and first released in 2014. It bundles a test runner, assertion library, mocking tools and snapshot testing into one package, which is why it became the default for most React and Node projects over the last decade.

It runs tests in parallel across worker processes, isolates each test file in its own module registry, and ships with coverage reporting and a watch mode out of the box. The project moved to the OpenJS Foundation in 2022, and the maintainers now ship transforms, ESM support and a faster runtime on a regular cadence.

Type
JavaScript test framework and runner
First released
2014
License
MIT, free and permissive
Maintained by
OpenJS Foundation and community contributors
Typically used for
Unit tests, component tests, integration tests, snapshot tests across Node and browser code

The honest version

Jest pros and cons

No technology is all upside. This is where Jest earns its place and where it tends to cause trouble.

Where Jest is strong

  • One tool that covers the whole test stackRunner, assertions, mocks, timers and coverage all ship together, so a new project is usually one install and one config file away from a green test command.
  • Snapshot testing done wellCapturing render output or large JSON blobs into a committed file catches regressions that nobody would have remembered to write an explicit assertion for.
  • Parallel workers by defaultThe runner shards test files across worker processes without any extra configuration, which keeps big suites tolerable on modern laptops and CI boxes.
  • Deep React ecosystem supportReact Testing Library, Enzyme in older codebases, Next.js and Create React App all assume Jest is in the project, so documentation and examples match what you actually have.
  • Good mocking primitivesjest.mock, jest.spyOn and automatic module mocking cover most cases without pulling in a second library, and the API stays consistent across versions.
  • Rich watch modeThe interactive watch filter runs only the files touched since the last git commit, which makes TDD on a large repo feel closer to working on a small one.

Where Jest bites

  • ESM support is still a sharp edgeNode native ESM, TypeScript ESM output and Jest's own transformer stack have to agree on the same module shape, and when they disagree the error messages do not point at the real cause.
  • Snapshots rot without disciplineObsolete snapshots accumulate when components change, and teams start running with --updateSnapshot as a reflex, which makes the whole technique stop catching regressions.
  • Slower than the newer runnersVitest and Node's built in test runner are measurably faster on the same suite, and the gap is widest on monorepos with thousands of files.
  • Transform configuration is a project of its ownBabel, ts-jest, SWC and native ESM each have their own trade offs, and getting one combination working often means other presets stop working the same week.
  • Open handles keep the process aliveTimers, database pools and sockets that were not closed show up as a worker that refuses to exit, which hides as a flaky CI step rather than a clear failure.
  • Memory footprint on big suitesWorkers load the module graph per file, and a monorepo with heavy transitive dependencies can push each worker past a gigabyte, which starves CI runners.

Sound familiar?

Common Jest problems we fix

The Jest problems that bring people to us, and what you have once each one is fixed.

Cannot use import statement outside a module

ESM packages refuse to load

A dependency ships as ESM only, Jest's default transform ignores node_modules, and the test file crashes before any of your code runs. The remedy is usually a transformIgnorePatterns tweak or a move to native ESM mode.

Transforms aligned, modules load

Snapshot does not match stored snapshot

Snapshots drift after a UI refactor

Markup changed on purpose but nobody curated the snapshot file, so every pull request has forty red snapshot diffs that nobody reads carefully. We rebuild them in small, reviewable passes.

Snapshots trimmed and honest

Timeout, async callback was not invoked

Tests hang until the timeout fires

A promise that never resolves, a mock that forgot to call its done callback, or a fake timer that is holding a real one. We trace it to the specific await and fix the cause rather than raising the timeout.

Async tests finish on their own

Jest did not exit one second after the test run

The worker refuses to exit

A database pool, a redis connection or a setInterval that was never cleared is keeping the process alive. --detectOpenHandles finds it; the real fix is a teardown hook.

Clean exit on every run

Cannot find module '@/components/Button'

Path aliases break in tests but work in build

tsconfig paths or webpack aliases that the Jest moduleNameMapper has never heard of. Keeping both in sync usually needs a shared config rather than two lists.

Aliases resolve everywhere

Tests: 847 passed in 14m 22s

The suite takes longer than anyone wants to wait

No sharding, heavy module graph reloaded per file, and a handful of integration tests dragging the average up. Projects config and sharded CI cut it down hard.

Runs finish in minutes not quarters

ReferenceError: TextEncoder is not defined

jsdom is missing browser globals

Newer libraries assume Web Platform APIs that jsdom has not shipped yet. A tiny setup file or a move to a more complete environment usually resolves it.

Environment matches the code

A worker process has failed to exit gracefully

Flaky CI runs that pass locally

Memory pressure on the CI runner, a leaky teardown, or a maxWorkers setting that is too high for the box. We profile the suite and pick numbers that match the hardware.

CI green and repeatable

What we do

Jest help, from rescue to tuning

Call us for one failing suite, or hand us the whole test strategy.

Rescue
Red suites, timed out CI, or snapshots nobody trusts. We stabilise the run first and tidy the setup afterwards.
ESM and transformer sorting
Babel, ts-jest, SWC or native ESM picked for your project, with the transformIgnorePatterns and moduleNameMapper that match the real dependency graph.
Performance tuning
Sharding, projects config, worker counts and setup caching applied until the suite fits inside a CI step you are happy to block merges on.
Snapshot hygiene
Obsolete snapshots cleared, brittle ones rewritten as explicit assertions, and a review workflow that keeps the remaining ones meaningful.
Migrations
Moves on or off Jest done without losing coverage: Mocha to Jest, Jest to Vitest, or splitting unit and integration layers across runners.
Managed Tech
Ongoing suite health reviews, upgrade rehearsals, CI runtime budgets and a number to call when the test command turns red overnight.

How it works

From first message to fixed

  1. Look Free estimate

    Tell us what's going wrong. We look at it, then tell you plainly what's wrong and what it will cost.

  2. Fix

    We fix the cause, not the symptom. If something is down, getting it back up comes first.

  3. Harden

    Backups, monitoring, updates and access, so the same problem can't quietly come back.

  4. Hand back or stay on

    You get a plain-language write-up. Or we stay on for hosting, upkeep and new work.

Often found together

Running Jest alongside something else?

We work on the whole stack, so the problem can be wherever it actually is.

Questions

Jest questions

Something else? Call+1 737 727 7327

Why does Jest break on ESM packages from npm?

Jest runs through its transform pipeline, and by default that pipeline skips node_modules. If a dependency ships only as ESM, Node has to load it natively but Jest's default worker still wants CommonJS. The fix is either an entry in transformIgnorePatterns so that specific package is transpiled, or switching the whole project to native ESM mode with the right NODE_OPTIONS flag.

Should we move from Jest to Vitest?

Sometimes. Vitest is faster on Vite based projects and has nicer ESM defaults, but a working Jest setup with thousands of tests is not a free move. We benchmark both against your actual suite before recommending a switch, and we migrate in small batches rather than overnight.

How do we stop snapshots from rotting?

Treat a snapshot update like any other change: read the diff in review rather than running --updateSnapshot without looking. Use inline snapshots for small values, separate files for rendered output, and delete the ones for components that no longer exist rather than letting the obsolete list grow.

Why does our test suite take fifteen minutes?

Usually a combination of too many integration tests mixed into the unit suite, no sharding across CI runners, and workers that load too much of the module graph per file. We split the config into projects, shard the slow parts across parallel jobs, and move anything that hits a real service into its own command.

Can you help with flaky tests that only fail on CI?

Yes. Flakes almost always trace back to timing assumptions, shared state between tests, or memory pressure on the CI runner. We reproduce the failure locally with the same worker count, fix the underlying cause, and add safeguards so the same failure mode cannot sneak back.

How much does Jest help cost?

The estimate is free. Send us the config, the failing output, and a rough size of the suite, and we come back with a quote before anything is touched.

Free estimate

Jest giving you grief?

Tell us what you're running and what's going wrong. A person reads it and comes back with an estimate.

  • No charge to find out what it will take
  • If it's urgent, say so

Replies come from a person. By sending, you authorize us to email you back. No marketing.