Skip to content

Commit

Permalink
fix(doc): improve test runner timeout docs
Browse files Browse the repository at this point in the history
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: nodejs/node#43836
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
(cherry picked from commit 545ecc57360fad50c49c81b56ae25fcc99d38456)
  • Loading branch information
tniessen authored and aduh95 committed Jul 20, 2022
1 parent 0a81cfc commit 751ffc6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ internally.
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 @@ -374,6 +374,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 @@ -488,7 +493,7 @@ execution of the test function. This function does not return a value.
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

0 comments on commit 751ffc6

Please sign in to comment.