Skip to content

Jest is running in single thread, --maxWorkers does not work #1909

@psalkowski

Description

@psalkowski

Describe the Bug

The --max-workers or --maxWorkers or setting maxWorkers in angular.json, or even in jest.config.ts does not do anything. The tests are always running in single thread like --runInBand.

This have impact on:

  1. Performance - we loose whole power of jest and parallel execution
  2. NodeJS have bug which cause inaccurate code coverage with v8 provider (randomly drop down on some test scenarios). It happens only in single thread mode in Jest, but when running in parallel, the issue does not exist - v8 test coverage in jest is incorrect when upgrading to 20.10.0 nodejs/node#51251 (comment)

Minimal Reproduction

The simplest angular application with just jest builder with jest.config.ts having such configuration:

coverageProvider: 'v8',
collectCoverage: true,
coverageDirectory: 'coverage',
testEnvironment: 'jsdom',
coverageThreshold: {
  global: {
    branches: 100,
    functions: 100,
    lines: 100,
    statements: 100,
  },
},

Expected Behavior

We should be able to run Jest in parallel

Environment


Libs
- @angular/core version: 19.2.4
- @angular-devkit/build-angular version: @angular-devkit/build-angular
- @angular-builders/jest version: 19.0.0

For Tooling issues:
- Node version: v22.14.0
- Npm version: 11.2.0
- Platform: Mac

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions