Skip to content

Commit 3244217

Browse files
tniessentargos
authored andcommitted
doc: improve test runner timeout docs
Add a warning to clarify that it is not a reliable mechanism for cancelling tests. Fix the default value of the timeout option. Simplify and capitalize the YAML description field. PR-URL: #43836 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 26d63f0 commit 3244217

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

doc/api/test.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ added: REPLACEME
323323
changes:
324324
- version: REPLACEME
325325
pr-url: https://github.com/nodejs/node/pull/43505
326-
description: add a timeout to tests and allow setting it in options.
326+
description: Add a `timeout` option.
327327
-->
328328

329329
* `name` {string} The name of the test, which is displayed when reporting test
@@ -345,7 +345,7 @@ changes:
345345
the test is `TODO`. **Default:** `false`.
346346
* `timeout` {number} A number of milliseconds the test will fail after.
347347
If unspecified, subtests inherit this value from their parent.
348-
**Default:** `30_000`.
348+
**Default:** `Infinity`.
349349
* `fn` {Function|AsyncFunction} The function under test. The first argument
350350
to this function is a [`TestContext`][] object. If the test uses callbacks,
351351
the callback function is passed as the second argument. **Default:** A no-op
@@ -378,6 +378,11 @@ test('top level test', async (t) => {
378378
});
379379
```
380380

381+
The `timeout` option can be used to fail the test if it takes longer than
382+
`timeout` milliseconds to complete. However, it is not a reliable mechanism for
383+
canceling tests because a running test might block the application thread and
384+
thus prevent the scheduled cancellation.
385+
381386
## `describe([name][, options][, fn])`
382387

383388
* `name` {string} The name of the suite, which is displayed when reporting test
@@ -529,7 +534,7 @@ added: REPLACEME
529534
changes:
530535
- version: REPLACEME
531536
pr-url: https://github.com/nodejs/node/pull/43505
532-
description: add a timeout to tests and allow setting it in options.
537+
description: Add a `timeout` option.
533538
-->
534539

535540
* `name` {string} The name of the subtest, which is displayed when reporting
@@ -551,7 +556,7 @@ changes:
551556
the test is `TODO`. **Default:** `false`.
552557
* `timeout` {number} A number of milliseconds the test will fail after.
553558
If unspecified, subtests inherit this value from their parent.
554-
**Default:** `30_000`.
559+
**Default:** `Infinity`.
555560
* `fn` {Function|AsyncFunction} The function under test. The first argument
556561
to this function is a [`TestContext`][] object. If the test uses callbacks,
557562
the callback function is passed as the second argument. **Default:** A no-op

0 commit comments

Comments
 (0)