Open
Description
Version
29.7.0
Steps to reproduce
- Clone the demo repo
nvm use 20.10.0
npm ci
npm test packages/package-1/example.test.js -- --watch
You can reproduce this issue on any Node.js version starting at 18.13.0 by having a large number of projects
.
Expected behavior
--watch mode doesn't consume large amounts of resources and works fast.
Actual behavior
--watch mode is resource-intensive, works slowly and slows down the whole system.
Additional context
Why it's slow
findRepos is sluggish because of running a ton of childProcess.spawn
under the hood (three processes per each project). It worked fast enough until Node.js version 18.13.0 was released, and this issue still persists even in the latest Node version (21.5.0).
Performance footprint for 30s
node --inspect-brk ./node_modules/.bin/jest packages/package-1/example.test.js --watch
Node.js 18.13.0 (and any later ones)
Possible ways to solve it
- Update
execa
, the current version that you use (5.0.0) is quite outdated, the latest is 8.0.1, there were some optimisation tweaks - Don't get repos for all projects if there is only one repo: in my monorepos there is always only one git repo, so findRepos works for nothing 99% of the time. This can be solved by introducing not required jest config fields like
onlyOneRepo: boolean
orrepo: string
- ...
Environment
System:
OS: macOS 14.1.1
CPU: (10) arm64 Apple M1 Pro
Binaries:
Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
Yarn: 1.22.17 - /opt/homebrew/bin/yarn
npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
pnpm: 8.6.2 - /opt/homebrew/bin/pnpm
npmPackages:
jest: ^29.7.0 => 29.7.0