Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(jest): expose maxmaxWorkers property in jest config #1675

Merged
merged 1 commit into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -14645,6 +14645,7 @@ Name | Type | Description
**haste**?🔹 | <code>[javascript.HasteConfig](#projen-javascript-hasteconfig)</code> | This will be used to configure the behavior of jest-haste-map, Jest's internal file crawler/cache system.<br/>__*Default*__: {}
**injectGlobals**?🔹 | <code>boolean</code> | Insert Jest's globals (expect, test, describe, beforeEach etc.) into the global environment. If you set this to false, you should import from @jest/globals.<br/>__*Default*__: true
**maxConcurrency**?🔹 | <code>number</code> | A number limiting the number of tests that are allowed to run at the same time when using test.concurrent. Any test above this limit will be queued and executed once a slot is released.<br/>__*Default*__: 5
**maxWorkers**?🔹 | <code>string &#124; number</code> | Specifies the maximum number of workers the worker-pool will spawn for running tests.<br/>__*Default*__: the number of the cores available on your machine minus one for the main thread
**moduleDirectories**?🔹 | <code>Array<string></code> | An array of directory names to be searched recursively up from the requiring module's location.<br/>__*Default*__: ["node_modules"]
**moduleFileExtensions**?🔹 | <code>Array<string></code> | An array of file extensions your modules use.<br/>__*Default*__: ["js", "json", "jsx", "ts", "tsx", "node"]
**moduleNameMapper**?🔹 | <code>Map<string, string &#124; Array<string>></code> | A map from regular expressions to module names or to arrays of module names that allow to stub out resources, like images or styles with a single module.<br/>__*Default*__: null
Expand Down
9 changes: 9 additions & 0 deletions src/javascript/jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ export interface JestConfigOptions {
*/
readonly maxConcurrency?: number;

/**
* Specifies the maximum number of workers the worker-pool will spawn for running tests. In single run mode,
* this defaults to the number of the cores available on your machine minus one for the main thread
* In watch mode, this defaults to half of the available cores on your machine.
* For environments with variable CPUs available, you can use percentage based configuration: "maxWorkers": "50%"
* @default - the number of the cores available on your machine minus one for the main thread
*/
readonly maxWorkers?: number | string;

/**
* An array of directory names to be searched recursively up from the requiring module's location.
* Setting this option will override the default, if you wish to still search node_modules for packages
Expand Down
2 changes: 2 additions & 0 deletions test/jest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ test("Node Project Jest With Options Configured", () => {
automock: true,
bail: 5,
notify: false,
maxWorkers: 1,
},
},
});
Expand All @@ -75,6 +76,7 @@ test("Node Project Jest With Options Configured", () => {
expect(jest.automock).toEqual(true);
expect(jest.bail).toEqual(5);
expect(jest.notify).toEqual(false);
expect(jest.maxWorkers).toEqual(1);
});

test("Node Project Jest With Path Configured", () => {
Expand Down