File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ export default function getMaxWorkers(
2222 return parseWorkers ( defaultOptions . maxWorkers ) ;
2323 } else {
2424 // In watch mode, Jest should be unobtrusive and not use all available CPUs.
25- const numCpus = cpus ( ) ? cpus ( ) . length : 1 ;
25+ const cpusInfo = cpus ( ) ;
26+ const numCpus = cpusInfo ?. length ?? 1 ;
2627 const isWatchModeEnabled = argv . watch || argv . watchAll ;
2728 return Math . max (
2829 isWatchModeEnabled ? Math . floor ( numCpus / 2 ) : numCpus - 1 ,
@@ -42,7 +43,7 @@ const parseWorkers = (maxWorkers: string | number): number => {
4243 ) {
4344 const numCpus = cpus ( ) . length ;
4445 const workers = Math . floor ( ( parsed / 100 ) * numCpus ) ;
45- return workers >= 1 ? workers : 1 ;
46+ return Math . max ( workers , 1 ) ;
4647 }
4748
4849 return parsed > 0 ? parsed : 1 ;
You can’t perform that action at this time.
0 commit comments