Skip to content

feat: add JEST_MAX_WORKERS environment variable support#15944

Open
vitorveiga wants to merge 2 commits intojestjs:mainfrom
vitorveiga:feat/jest-max-workers-env-var
Open

feat: add JEST_MAX_WORKERS environment variable support#15944
vitorveiga wants to merge 2 commits intojestjs:mainfrom
vitorveiga:feat/jest-max-workers-env-var

Conversation

@vitorveiga
Copy link

@vitorveiga vitorveiga commented Jan 21, 2026

Summary

  • Adds support for setting maxWorkers via the JEST_MAX_WORKERS environment variable
  • Provides a convenient way to control worker count in CI environments without modifying configuration files or CLI arguments
  • Supports both numeric values (e.g., "4") and percentage-based values (e.g., "50%")

Changes

  • packages/jest-config/src/getMaxWorkers.ts: Added check for process.env.JEST_MAX_WORKERS in the resolution priority chain
  • packages/jest-config/src/__tests__/getMaxWorkers.test.ts: Added 5 new unit tests covering the environment variable functionality, priority order, and percentage support
  • docs/Configuration.md: Updated the maxWorkers documentation section to explain the priority order and usage of JEST_MAX_WORKERS

Priority Order

The maxWorkers option is now resolved in the following order:

  1. argv.maxWorkers (CLI argument)
  2. defaultOptions.maxWorkers (configuration file)
  3. process.env.JEST_MAX_WORKERS (environment variable) ⬅️ new
  4. CPU-based defaults

Test Plan

  • Built the project with yarn build:js
  • Linted modified files (no errors)
  • All 12 unit tests in getMaxWorkers.test.ts pass, including 5 new tests for the environment variable
  • Verified environment variable supports numeric and percentage values
  • Verified priority order is respected

Add support for setting maxWorkers via the JEST_MAX_WORKERS environment
variable. This provides a convenient way to control worker count in CI
environments without modifying configuration files or CLI arguments.

Priority order: argv.maxWorkers > defaultOptions.maxWorkers >
JEST_MAX_WORKERS > CPU-based defaults.

The environment variable supports both numeric values and percentage-based
values (e.g., "50%"), consistent with existing maxWorkers behavior.
@netlify
Copy link

netlify bot commented Jan 21, 2026

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 66d1082
🔍 Latest deploy log https://app.netlify.com/projects/jestjs/deploys/6970de1755a045000886b136
😎 Deploy Preview https://deploy-preview-15944--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jan 21, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 21, 2026

Open in StackBlitz

babel-jest

npm i https://pkg.pr.new/babel-jest@15944

babel-plugin-jest-hoist

npm i https://pkg.pr.new/babel-plugin-jest-hoist@15944

babel-preset-jest

npm i https://pkg.pr.new/babel-preset-jest@15944

create-jest

npm i https://pkg.pr.new/create-jest@15944

@jest/diff-sequences

npm i https://pkg.pr.new/@jest/diff-sequences@15944

expect

npm i https://pkg.pr.new/expect@15944

@jest/expect-utils

npm i https://pkg.pr.new/@jest/expect-utils@15944

jest

npm i https://pkg.pr.new/jest@15944

jest-changed-files

npm i https://pkg.pr.new/jest-changed-files@15944

jest-circus

npm i https://pkg.pr.new/jest-circus@15944

jest-cli

npm i https://pkg.pr.new/jest-cli@15944

jest-config

npm i https://pkg.pr.new/jest-config@15944

@jest/console

npm i https://pkg.pr.new/@jest/console@15944

@jest/core

npm i https://pkg.pr.new/@jest/core@15944

@jest/create-cache-key-function

npm i https://pkg.pr.new/@jest/create-cache-key-function@15944

jest-diff

npm i https://pkg.pr.new/jest-diff@15944

jest-docblock

npm i https://pkg.pr.new/jest-docblock@15944

jest-each

npm i https://pkg.pr.new/jest-each@15944

@jest/environment

npm i https://pkg.pr.new/@jest/environment@15944

jest-environment-jsdom

npm i https://pkg.pr.new/jest-environment-jsdom@15944

@jest/environment-jsdom-abstract

npm i https://pkg.pr.new/@jest/environment-jsdom-abstract@15944

jest-environment-node

npm i https://pkg.pr.new/jest-environment-node@15944

@jest/expect

npm i https://pkg.pr.new/@jest/expect@15944

@jest/fake-timers

npm i https://pkg.pr.new/@jest/fake-timers@15944

@jest/get-type

npm i https://pkg.pr.new/@jest/get-type@15944

@jest/globals

npm i https://pkg.pr.new/@jest/globals@15944

jest-haste-map

npm i https://pkg.pr.new/jest-haste-map@15944

jest-jasmine2

npm i https://pkg.pr.new/jest-jasmine2@15944

jest-leak-detector

npm i https://pkg.pr.new/jest-leak-detector@15944

jest-matcher-utils

npm i https://pkg.pr.new/jest-matcher-utils@15944

jest-message-util

npm i https://pkg.pr.new/jest-message-util@15944

jest-mock

npm i https://pkg.pr.new/jest-mock@15944

@jest/pattern

npm i https://pkg.pr.new/@jest/pattern@15944

jest-phabricator

npm i https://pkg.pr.new/jest-phabricator@15944

jest-regex-util

npm i https://pkg.pr.new/jest-regex-util@15944

@jest/reporters

npm i https://pkg.pr.new/@jest/reporters@15944

jest-resolve

npm i https://pkg.pr.new/jest-resolve@15944

jest-resolve-dependencies

npm i https://pkg.pr.new/jest-resolve-dependencies@15944

jest-runner

npm i https://pkg.pr.new/jest-runner@15944

jest-runtime

npm i https://pkg.pr.new/jest-runtime@15944

@jest/schemas

npm i https://pkg.pr.new/@jest/schemas@15944

jest-snapshot

npm i https://pkg.pr.new/jest-snapshot@15944

@jest/snapshot-utils

npm i https://pkg.pr.new/@jest/snapshot-utils@15944

@jest/source-map

npm i https://pkg.pr.new/@jest/source-map@15944

@jest/test-result

npm i https://pkg.pr.new/@jest/test-result@15944

@jest/test-sequencer

npm i https://pkg.pr.new/@jest/test-sequencer@15944

@jest/transform

npm i https://pkg.pr.new/@jest/transform@15944

@jest/types

npm i https://pkg.pr.new/@jest/types@15944

jest-util

npm i https://pkg.pr.new/jest-util@15944

jest-validate

npm i https://pkg.pr.new/jest-validate@15944

jest-watcher

npm i https://pkg.pr.new/jest-watcher@15944

jest-worker

npm i https://pkg.pr.new/jest-worker@15944

pretty-format

npm i https://pkg.pr.new/pretty-format@15944

commit: 66d1082

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant