Skip to content

feat: add JEST_MAX_WORKERS environment variable support#1

Open
vitorveiga wants to merge 121 commits into
mainfrom
feat/jest-max-workers-env-var
Open

feat: add JEST_MAX_WORKERS environment variable support#1
vitorveiga wants to merge 121 commits into
mainfrom
feat/jest-max-workers-env-var

Conversation

@vitorveiga

Copy link
Copy Markdown
Owner

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

🤖 Generated with Claude Code

vitorveiga and others added 30 commits January 21, 2026 13:53
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.
…#16009)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…updates (jestjs#16007)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…date (jestjs#16059)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…jestjs#15977)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
SimenB and others added 30 commits May 7, 2026 20:41
…oup across 1 directory (jestjs#16149)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(runtime): avoid magical `null` value

* changelog

* review comments

* another fix

* constant

* sorted

* ah, not here
Co-authored-by: Tim Seckinger <github@jeys.al>
Also add specific instructions to many packages
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.