From 94f9b70e8b02b793c4e8a71c830c7c70aac3f8f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Thu, 20 Apr 2023 15:43:05 +0200 Subject: [PATCH] doc: clarify concurrency model of test runner Refs: https://github.com/nodejs/node/issues/47365 --- doc/api/test.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/api/test.md b/doc/api/test.md index 4b33b37e11fbf3e..2134630050b3a54 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -379,6 +379,11 @@ Otherwise, the test is considered to be a failure. Test files must be executable by Node.js, but are not required to use the `node:test` module internally. +Each test file is executed as if it was a regular script. That is, if the test +file itself uses `node:test` to define tests, all of those tests will be +executed within a single application thread, regardless of the value of the +`concurrency` option of [`test()`][]. + ## Collecting code coverage > Stability: 1 - Experimental @@ -731,7 +736,8 @@ added: * `options` {Object} Configuration options for running tests. The following properties are supported: * `concurrency` {number|boolean} If a number is provided, - then that many files would run in parallel. + then that many test processes would run in parallel, where each process + corresponds to one test file. If `true`, it would run `os.availableParallelism() - 1` test files in parallel. If `false`, it would only run one test file at a time. @@ -795,7 +801,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. + then that many tests would run in parallel within the application thread. If `true`, it would run `os.availableParallelism() - 1` tests in parallel. For subtests, it will be `Infinity` tests in parallel. If `false`, it would only run one test at a time. @@ -1765,8 +1771,8 @@ changes: `fn` does not have a name. * `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. + * `concurrency` {number|boolean} If a number is provided, + then that many tests would run in parallel within the application thread. If `true`, it would run all subtests in parallel. If `false`, it would only run one test at a time. If unspecified, subtests inherit this value from their parent.