-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
doc: correct concurrency wording in test() documentation #60773
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
Merged
nodejs-github-bot
merged 2 commits into
nodejs:main
from
azadgupta1:doc-fix-test-runner-concurrency
Nov 20, 2025
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1619,7 +1619,7 @@ changes: | |||||||||
| * `options` {Object} Configuration options for the test. The following | ||||||||||
| properties are supported: | ||||||||||
| * `concurrency` {number|boolean} If a number is provided, | ||||||||||
| then that many tests would run in parallel within the application thread. | ||||||||||
| then that many tests would run concurrently within the test process. | ||||||||||
| If `true`, all scheduled asynchronous tests run concurrently within the | ||||||||||
| thread. If `false`, only one test runs at a time. | ||||||||||
| If unspecified, subtests inherit this value from their parent. | ||||||||||
|
|
@@ -3882,7 +3882,7 @@ changes: | |||||||||
| * `options` {Object} Configuration options for the subtest. The following | ||||||||||
| properties are supported: | ||||||||||
| * `concurrency` {number|boolean|null} If a number is provided, | ||||||||||
| then that many tests would run in parallel within the application thread. | ||||||||||
| then that many tests would run concurrently within the test process. | ||||||||||
| If `true`, it would run all subtests in parallel. | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably also get rid of the other mentions of "parallel" (non blocking, can also happen in a follow up PR)
Suggested change
or
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer "asynchronously" |
||||||||||
| If `false`, it would only run one test at a time. | ||||||||||
| If unspecified, subtests inherit this value from their parent. | ||||||||||
|
|
||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it clarifies, specifying
concurrencyonly affects the current thread, IMO talking about "process" muddies the water.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also not always correct: isolation none runs the tests in the main process (instead of a dedicated test process).
"Thread" is indeed wrong though, and that affects shared globals, so maybe that should be corrected. I think there may be a circumstance where it uses threads instead of processes though, but that may not be the case (anymore?). I'd have to check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any case where
test({ concurrency: true }, …)would result in creating multiple threads / processes? I don't think that's a thing, I feel like we're talking about different things.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Processes: no, never (each test file gets its own process though)
Threads: I believe it uses
Promise.allSettledwhenconcurrency: true(whenconcurrency: number, I think it uses threads)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
Promise.allSettledwould make more sense, because that runs in the same thread. Test files written in JS are no different for other JS files: if making a JS file multi-threaded was as easy as setting a boolean value, we would not reserve it only to tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its just a queue of promises
node/lib/internal/test_runner/test.js
Lines 989 to 1000 in 0b6ae6d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And to be clear we are explicitly talking about the
concurrencyoption for a suite or test function. Such assuite('foo', { concurrency: number | boolean }, () => {});ortest('bar', { concurrency: number | boolean }, () => {});The
concurrencyoption forrun()or the CLI args does use processes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know 🙂
It would probably be easiest to find the original PR that introduced it (there was specific discussion around Boolean vs number, so the answer will be there).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO if we think talking about "thread" is bad because there's only one thread, it makes no sense to replace it with "process", for the same reason. Maybe we can find an alternative wording, e.g.:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I better understand your reasoning now. I think your proposed wording is much clearer.