File tree 1 file changed +3
-2
lines changed
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(
22
22
return parseWorkers ( defaultOptions . maxWorkers ) ;
23
23
} else {
24
24
// 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 ;
26
27
const isWatchModeEnabled = argv . watch || argv . watchAll ;
27
28
return Math . max (
28
29
isWatchModeEnabled ? Math . floor ( numCpus / 2 ) : numCpus - 1 ,
@@ -42,7 +43,7 @@ const parseWorkers = (maxWorkers: string | number): number => {
42
43
) {
43
44
const numCpus = cpus ( ) . length ;
44
45
const workers = Math . floor ( ( parsed / 100 ) * numCpus ) ;
45
- return workers >= 1 ? workers : 1 ;
46
+ return Math . max ( workers , 1 ) ;
46
47
}
47
48
48
49
return parsed > 0 ? parsed : 1 ;
You can’t perform that action at this time.
0 commit comments