We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 024295c commit 1d8f955Copy full SHA for 1d8f955
1 file changed
packages/jest-config/src/getMaxWorkers.ts
@@ -22,7 +22,8 @@ export default function getMaxWorkers(
22
return parseWorkers(defaultOptions.maxWorkers);
23
} else {
24
// In watch mode, Jest should be unobtrusive and not use all available CPUs.
25
- const numCpus = cpus() ? cpus().length : 1;
+ const cpusInfo = cpus();
26
+ const numCpus = cpusInfo?.length ?? 1;
27
const isWatchModeEnabled = argv.watch || argv.watchAll;
28
return Math.max(
29
isWatchModeEnabled ? Math.floor(numCpus / 2) : numCpus - 1,
@@ -42,7 +43,7 @@ const parseWorkers = (maxWorkers: string | number): number => {
42
43
) {
44
const numCpus = cpus().length;
45
const workers = Math.floor((parsed / 100) * numCpus);
- return workers >= 1 ? workers : 1;
46
+ return Math.max(workers, 1);
47
}
48
49
return parsed > 0 ? parsed : 1;
0 commit comments