diff options
author | Chemi Atlow <chemi@testim.io> | 2023-04-18 23:59:49 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-18 20:59:49 +0000 |
commit | 2ec4ef7c24a0b1c63ac54a9a042790eee4a01040 (patch) | |
tree | 03edbcaf86f04d22d09a96cb02cc58e67eda1788 /doc/api | |
parent | 9b6f7f0deddd86a84b909ee08c56a84613996466 (diff) | |
download | node-new-2ec4ef7c24a0b1c63ac54a9a042790eee4a01040.tar.gz |
test_runner: execute before hook on test
Execute the before hook for Test as well, and execute it on root before
executing any tests.
Fixes: https://github.com/nodejs/node/issues/47518
PR-URL: https://github.com/nodejs/node/pull/47586
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Diffstat (limited to 'doc/api')
-rw-r--r-- | doc/api/test.md | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/doc/api/test.md b/doc/api/test.md index 2a7cfecf8f..4b33b37e11 100644 --- a/doc/api/test.md +++ b/doc/api/test.md @@ -1498,12 +1498,36 @@ Emitted when a test starts. added: - v18.0.0 - v16.17.0 +changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/47586 + description: The `before` function was added to TestContext. --> An instance of `TestContext` is passed to each test function in order to interact with the test runner. However, the `TestContext` constructor is not exposed as part of the API. +### `context.before([fn][, options])` + +<!-- YAML +added: REPLACEME +--> + +* `fn` {Function|AsyncFunction} The hook function. The first argument + to this function is a [`TestContext`][] object. If the hook uses callbacks, + the callback function is passed as the second argument. **Default:** A no-op + function. +* `options` {Object} Configuration options for the hook. The following + properties are supported: + * `signal` {AbortSignal} Allows aborting an in-progress hook. + * `timeout` {number} A number of milliseconds the hook will fail after. + If unspecified, subtests inherit this value from their parent. + **Default:** `Infinity`. + +This function is used to create a hook running before +subtest of the current test. + ### `context.beforeEach([fn][, options])` <!-- YAML |