mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
doc: add note (and caveat) for mock.module about customization hooks
PR-URL: https://github.com/nodejs/node/pull/62075 Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
This commit is contained in:
1 parent
8aa6e706df
commit
44bde8e573
1 file changed
+6
@@ -2494,6 +2494,11 @@ Node.js builtin modules. Any references to the original module prior to mocking
|
||||
order to enable module mocking, Node.js must be started with the
|
||||
[`--experimental-test-module-mocks`][] command-line flag.
|
||||
|
||||
**Note**: [module customization hooks][] registered via the **synchronous** API effect resolution of
|
||||
the `specifier` provided to `mock.module`. Customization hooks registered via the **asynchronous**
|
||||
API are currently ignored (because the test runner's loader is synchronous, and node does not
|
||||
support multi-chain / cross-chain loading).
|
||||
|
||||
The following example demonstrates how a mock is created for a module.
|
||||
|
||||
```js
|
||||
@@ -4239,6 +4244,7 @@ Can be used to abort test subtasks when the test has been aborted.
|
||||
[configuration files]: cli.md#--experimental-config-fileconfig
|
||||
[describe options]: #describename-options-fn
|
||||
[it options]: #testname-options-fn
|
||||
[module customization hooks]: module.md#customization-hooks
|
||||
[running tests from the command line]: #running-tests-from-the-command-line
|
||||
[stream.compose]: stream.md#streamcomposestreams
|
||||
[subtests]: #subtests
|
||||
|
||||
Reference in new issue
Block a user