Skip to content

Commit 670c808

Browse files
JakobJingleheimeraduh95
authored andcommitted
doc: add note (and caveat) for mock.module about customization hooks
PR-URL: #62075 Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
1 parent 4d96e53 commit 670c808

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

doc/api/test.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2497,6 +2497,11 @@ Node.js builtin modules. Any references to the original module prior to mocking
24972497
order to enable module mocking, Node.js must be started with the
24982498
[`--experimental-test-module-mocks`][] command-line flag.
24992499

2500+
**Note**: [module customization hooks][] registered via the **synchronous** API effect resolution of
2501+
the `specifier` provided to `mock.module`. Customization hooks registered via the **asynchronous**
2502+
API are currently ignored (because the test runner's loader is synchronous, and node does not
2503+
support multi-chain / cross-chain loading).
2504+
25002505
The following example demonstrates how a mock is created for a module.
25012506

25022507
```js
@@ -4244,6 +4249,7 @@ Can be used to abort test subtasks when the test has been aborted.
42444249
[configuration files]: cli.md#--experimental-config-fileconfig
42454250
[describe options]: #describename-options-fn
42464251
[it options]: #testname-options-fn
4252+
[module customization hooks]: module.md#customization-hooks
42474253
[running tests from the command line]: #running-tests-from-the-command-line
42484254
[stream.compose]: stream.md#streamcomposestreams
42494255
[subtests]: #subtests

0 commit comments

Comments
 (0)