Skip to content

Commit e57d5bb

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

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
@@ -2500,6 +2500,11 @@ Node.js builtin modules. Any references to the original module prior to mocking
25002500
order to enable module mocking, Node.js must be started with the
25012501
[`--experimental-test-module-mocks`][] command-line flag.
25022502

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

25052510
```js
@@ -4247,6 +4252,7 @@ Can be used to abort test subtasks when the test has been aborted.
42474252
[configuration files]: cli.md#--experimental-config-fileconfig
42484253
[describe options]: #describename-options-fn
42494254
[it options]: #testname-options-fn
4255+
[module customization hooks]: module.md#customization-hooks
42504256
[running tests from the command line]: #running-tests-from-the-command-line
42514257
[stream.compose]: stream.md#streamcomposestreams
42524258
[subtests]: #subtests

0 commit comments

Comments
 (0)