@@ -97,7 +97,7 @@ replaces all functions it encounters with fake test double functions which can,
97
97
in turn, be configured by your test to either stub responses or assert
98
98
invocations.
99
99
100
- Additionally, if you're using Node 16 or newer , you can replace native ES modules with ` td.replaceEsm() ` . More details
100
+ For ES modules , you should use ` td.replaceEsm() ` . More details
101
101
[ here] ( docs/7-replacing-dependencies.md#how-module-replacement-works-for-es-modules-using-import ) .
102
102
103
103
#### Module replacement with Node.js
@@ -568,6 +568,36 @@ completeness—a test will verify an invocation that already satisfied a stubbin
568
568
but this is almost [ provably
569
569
unnecessary] ( /docs/B-frequently-asked-questions.md#why-shouldnt-i-call-both-tdwhen-and-tdverify-for-a-single-interaction-with-a-test-double ) .
570
570
571
+ ### ` td.listReplacedModules() ` for listing the modules that were replaced
572
+
573
+ ** ` td.listReplacedModules() ` **
574
+
575
+
576
+ Use ` td.listReplacedModules() ` to list the modules that are replaced. This function will return an array of the modules that are
577
+ currently being replaced via ` td.replace() ` or ` td.replaceEsm() ` .
578
+
579
+ The list is in no particular order, and returns the full path to the module that was replaced.
580
+ The path is returned as a ` file: ` URL as is customary in ESM (this is true even if the
581
+ replaced module was CJS).
582
+
583
+ For example, if you do this:
584
+
585
+ ``` js
586
+ td .replace (' ../src/save' )
587
+ ```
588
+
589
+ Then
590
+
591
+ ``` js
592
+ td .listReplacedModules ()
593
+ ```
594
+
595
+ will return something like:
596
+
597
+ ``` js
598
+ [' file:///users/example/code/foo/src/save.js' ]
599
+ ```
600
+
571
601
### Other functions
572
602
573
603
For other top-level features in the testdouble.js API, consult the [ docs] ( /docs )
0 commit comments