Skip to content

Commit aa7d4e5

Browse files
tniessendanielleadams
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 aa8053e commit aa7d4e5

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: v18.0.0
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
@@ -346,7 +346,7 @@ changes:
346346
the test is `TODO`. **Default:** `false`.
347347
* `timeout` {number} A number of milliseconds the test will fail after.
348348
If unspecified, subtests inherit this value from their parent.
349-
**Default:** `30_000`.
349+
**Default:** `Infinity`.
350350
* `fn` {Function|AsyncFunction} The function under test. The first argument
351351
to this function is a [`TestContext`][] object. If the test uses callbacks,
352352
the callback function is passed as the second argument. **Default:** A no-op
@@ -379,6 +379,11 @@ test('top level test', async (t) => {
379379
});
380380
```
381381

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

384389
* `name` {string} The name of the suite, which is displayed when reporting test
@@ -545,7 +550,7 @@ added: v18.0.0
545550
changes:
546551
- version: REPLACEME
547552
pr-url: https://github.com/nodejs/node/pull/43505
548-
description: add a timeout to tests and allow setting it in options.
553+
description: Add a `timeout` option.
549554
-->
550555

551556
* `name` {string} The name of the subtest, which is displayed when reporting
@@ -567,7 +572,7 @@ changes:
567572
the test is `TODO`. **Default:** `false`.
568573
* `timeout` {number} A number of milliseconds the test will fail after.
569574
If unspecified, subtests inherit this value from their parent.
570-
**Default:** `30_000`.
575+
**Default:** `Infinity`.
571576
* `fn` {Function|AsyncFunction} The function under test. The first argument
572577
to this function is a [`TestContext`][] object. If the test uses callbacks,
573578
the callback function is passed as the second argument. **Default:** A no-op

0 commit comments

Comments
 (0)