Skip to content

Commit

Permalink
fix: fix WORKERS_COUNT not found (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge authored Feb 15, 2024
1 parent 018b010 commit 6897b22
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/jest-environment-puppeteer/src/browsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,19 @@ export const startBrowsers = async ({
config: JestPuppeteerConfig;
jestConfig: JestConfig;
}): Promise<Browser[]> => {
const workersCount = getWorkersCount(jestConfig);
saveWorkersCount(workersCount);

if (config.connect?.browserWSEndpoint) {
if (workersCount > 1) {
throw new Error(
"Cannot use `connect.browserWSEndpoint` with multiple workers. Set Jest `maxWorkers` to 1.",
);
}
saveWsEndpoints([config.connect.browserWSEndpoint]);
return [];
}

const workersCount = getWorkersCount(jestConfig);
saveWorkersCount(workersCount);

const browsers = await Promise.all(
Array.from({ length: workersCount }).map(() => openBrowser(config)),
);
Expand Down

0 comments on commit 6897b22

Please sign in to comment.