Skip to content

Commit

Permalink
Update test mocks and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
robhogan authored Oct 31, 2024
1 parent 0d9312b commit af62dde
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ If `true`, Metro will use a stable mapping from files to transformer workers, so

Type: `number`

The number of workers to use for parallel processing in Metro. Defaults to approximately half of the number of cores available on the machine, as reported by [`os.cpus()`](https://nodejs.org/api/os.html#oscpus).
The number of workers to use for parallel processing in Metro. Defaults to approximately half of the number of cores available on the machine, as reported by [`os.availableParallelism()`](https://nodejs.org/api/os.html#availableparallelism).

:::note
1. Values exceeding the number of available cores have no effect.
Expand Down
6 changes: 3 additions & 3 deletions packages/metro/src/lib/__tests__/getMaxWorkers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ test('calculates the number of max workers', () => {
/* $FlowFixMe(>=0.99.0 site=react_native_fb) This comment suppresses an error
* found when Flow v0.99 was deployed. To see the error, delete this comment
* and run Flow. */
os.cpus.mockReturnValue({length: 1});
os.availableParallelism.mockReturnValue({length: 1});
expect(getMaxWorkers()).toBe(1);
/* $FlowFixMe(>=0.99.0 site=react_native_fb) This comment suppresses an error
* found when Flow v0.99 was deployed. To see the error, delete this comment
* and run Flow. */
os.cpus.mockReturnValue({length: 8});
os.availableParallelism.mockReturnValue({length: 8});
expect(getMaxWorkers()).toBe(6);
/* $FlowFixMe(>=0.99.0 site=react_native_fb) This comment suppresses an error
* found when Flow v0.99 was deployed. To see the error, delete this comment
* and run Flow. */
os.cpus.mockReturnValue({length: 24});
os.availableParallelism.mockReturnValue({length: 24});
expect(getMaxWorkers()).toBe(14);
expect(getMaxWorkers(5)).toBe(5);
});

0 comments on commit af62dde

Please sign in to comment.