jest projects config not picking up all packages: monorepo fix
Fixes jest `projects` config that misses packages in a monorepo. Use it when some packages never run or configs are silently ignored. Not for single-package jest setup or non-jest monorepo tooling.
TL;DR
When jest projects misses packages it is usually a glob problem: the pattern does not match the package dir, or a matched package has no config file for jest to find. List each package explicitly or use a glob that matches every package root, and make sure each entry points at a directory containing a jest config (or pass the config object inline). Run npx jest --listTests to see exactly which projects jest discovered before debugging further.
The query
jest projects config not picking up all packages: monorepo fixUse this when
jest --projectsruns only some monorepo packages- A new package's tests never execute in CI
- Per-package jest configs seem to be ignored
- Migrating a monorepo from per-package runs to one jest invocation
Not for
- Single-package jest configuration
- Turborepo / nx task orchestration issues
- Module resolution errors inside a found package
Steps
- Run
npx jest --listTestsand compare the output against your full package list. Expected output: the test list shows exactly which packages jest discovered; missing ones are confirmed absent. - Inspect the
projectsglobs in the root config and test each against the real directory layout (a glob like[packages]/*silently skips nested or oddly named dirs). Expected output: you identify the glob entries that fail to match the missing packages. - Fix the match: widen the glob or list package dirs explicitly, and verify each listed dir contains a jest config file (package.json
jestkey or jest.config). Expected output: every package dir resolves to a discoverable config. - Re-run
--listTestsand then the suite, confirming all packages appear and run. Expected output: test count matches the sum across packages; CI runs everything.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_BkO8uU5UN-n3ctseGJpAiA
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.