Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 44bde8e

Browse filesBrowse 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 8aa6e70 commit 44bde8e
Copy full SHA for 44bde8e

1 file changed

+6Lines changed: 6 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/test.md‎

Copy file name to clipboardExpand all lines: doc/api/test.md
+6Lines changed: 6 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2494,6 +2494,11 @@ Node.js builtin modules. Any references to the original module prior to mocking
24942494
order to enable module mocking, Node.js must be started with the
24952495
[`--experimental-test-module-mocks`][] command-line flag.
24962496

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

24992504
```js
@@ -4239,6 +4244,7 @@ Can be used to abort test subtasks when the test has been aborted.
42394244
[configuration files]: cli.md#--experimental-config-fileconfig
42404245
[describe options]: #describename-options-fn
42414246
[it options]: #testname-options-fn
4247+
[module customization hooks]: module.md#customization-hooks
42424248
[running tests from the command line]: #running-tests-from-the-command-line
42434249
[stream.compose]: stream.md#streamcomposestreams
42444250
[subtests]: #subtests

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.