fix: throw error when workers option is not number or percentage (#31210)
This commit is contained in:
parent
e280d0bd35
commit
abaddc01c9
|
|
@ -107,7 +107,7 @@ export class FullConfigInternal {
|
||||||
const cpus = os.cpus().length;
|
const cpus = os.cpus().length;
|
||||||
this.config.workers = Math.max(1, Math.floor(cpus * (parseInt(workers, 10) / 100)));
|
this.config.workers = Math.max(1, Math.floor(cpus * (parseInt(workers, 10) / 100)));
|
||||||
} else {
|
} else {
|
||||||
this.config.workers = parseInt(workers, 10);
|
this.config.workers = parseWorkers(workers);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.config.workers = workers;
|
this.config.workers = workers;
|
||||||
|
|
@ -223,6 +223,14 @@ function resolveReporters(reporters: Config['reporter'], rootDir: string): Repor
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseWorkers(workers: string) {
|
||||||
|
const parsedWorkers = parseInt(workers, 10);
|
||||||
|
if (isNaN(parsedWorkers))
|
||||||
|
throw new Error(`Workers ${workers} must be a number or percentage.`);
|
||||||
|
|
||||||
|
return parsedWorkers;
|
||||||
|
}
|
||||||
|
|
||||||
function resolveProjectDependencies(projects: FullProjectInternal[]) {
|
function resolveProjectDependencies(projects: FullProjectInternal[]) {
|
||||||
const teardownSet = new Set<FullProjectInternal>();
|
const teardownSet = new Set<FullProjectInternal>();
|
||||||
for (const project of projects) {
|
for (const project of projects) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue