Skip to content

Commit 1d01c6f

Browse files
doc: add note (and caveat) for mock.module about customization hooks
1 parent f8d5bad commit 1d01c6f

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

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

25132518
```js
@@ -4255,6 +4260,7 @@ Can be used to abort test subtasks when the test has been aborted.
42554260
[configuration files]: cli.md#--experimental-config-fileconfig
42564261
[describe options]: #describename-options-fn
42574262
[it options]: #testname-options-fn
4263+
[module customization hooks]: module.md#customization-hooks
42584264
[running tests from the command line]: #running-tests-from-the-command-line
42594265
[stream.compose]: stream.md#streamcomposestreams
42604266
[subtests]: #subtests

0 commit comments

Comments
 (0)