Open patrickhousley opened 2 months ago
Hi,
How is your monorepo set up? If you have only one workspace folder, you can use Jest's configuration (such as maxWorkers
) to limit the parallel threads. However, if you have multiple workspace folders (multi-root workspace) or are using jest.virtualFolders
, then, currently, each eligible folder will spawn its own Jest process. In this case, using such configuration options can help limit resource consumption.
This is a large Nx workspace with 200+ apps/libs. I started with trying to setup each app/lib in jest.virtualFolders
but that ended up slowing down vscode, my computer, etc and listing every project in the footer bar pushed all other useful info down there off the screen. Right now I am using:
"jest.outputConfig": "test-results-based",
"jest.runMode": "on-demand",
"jest.jestCommandLine": "npm run jest -- --config ./jest.config.ts",
This takes care of most of the annoyances and is probably the right way to configure such a large mono-repo. I figured the plugin could be improved to use some form of a thread/process pool for virtual folders. Even on smaller mono-repos it might be nice to be able to limit the number of parallel running jest instances. Just a thought, feel free to close if you are not amicable to the idea.
Is your feature request related to a problem? Please describe. Not really an issue but clicking the "run all" button in a mono-repo with 200+ packages or configuring auto-run can peg CPU to a point that it can cause machine instability. Even just running the process to get the list of test files when vscode is opened can cause issues.
Describe the solution you'd like Can we add a configuration option to limit the number of parallel threads or possibly limit the number of child processes spawned in parallel to the number of CPU cores?