Skip to content
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

doc: improve test runner timeout docs #43836

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions doc/api/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ added: v18.0.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/43505
description: add a timeout to tests and allow setting it in options.
description: Add a `timeout` option.
-->

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

The `timeout` option can be used to fail the test if it takes longer than
`timeout` milliseconds to complete. However, it is not a reliable mechanism for
canceling tests because a running test might block the application thread and
thus prevent the scheduled cancellation.

## `describe([name][, options][, fn])`

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

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