Skip to content

Commit 1fc86fc

Browse files
JakobJingleheimermarco-ippolito
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 491be80 commit 1fc86fc

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

doc/api/test.md

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

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

22272232
```js
@@ -3886,6 +3891,7 @@ Can be used to abort test subtasks when the test has been aborted.
38863891
[code coverage]: #collecting-code-coverage
38873892
[describe options]: #describename-options-fn
38883893
[it options]: #testname-options-fn
3894+
[module customization hooks]: module.md#customization-hooks
38893895
[running tests from the command line]: #running-tests-from-the-command-line
38903896
[stream.compose]: stream.md#streamcomposestreams
38913897
[subtests]: #subtests

0 commit comments

Comments
 (0)