-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get list of mocked modules #519
Comments
This may be reachable without modification if you want to investigate. I'd look for references to these values as a starting point, since they're what gets reset in the ESM loader. (Module replacement is handled by another module we own called quibble.) I'd be open to a PR to Quibble and/or testdouble.js itself that provided this information if it's not reachable any other way, because I agree this would be interesting to know from a debugging perspective. However, I've been out of this codebase so long I don't know how much help I'd be. CC/ @giltayar since he was in the quibble code most recently |
Hmm, it looks like from the code you cited that it does not expose this (that code handles only registration and de-registration of module mocks). On a related note: I noticed that is using EDIT: By "any day", I apparently meant today: https://nodejs.org/en/blog/release/v21.0.0
|
The current code is an archeological dig that shows all the layers of how to implement ESM Loaders, from the first to the last 😁. We currently support Node 16, 18, and 20 (with the new "register"). Which is why we have both I plan on removing all these archeological layers and cleaning up the code once 18 disappears from the map. Till then, |
We definitely have the information in Note that the list of modules will not include their original name (e.g. I can try and do something, but just as a curiosity: why would you need this list? |
For my immediate need: I have a globally mocked module (which otherwise accesses indexeddb that doesn't exist in node). The module is mocked via mocha's global before/each. In a particular test, it throws that indexeddb doesn't exist, which means something is failing. I want to confirm that testdouble doesn't think it's mocked and hopefully pinpoint why it is not mocked. I suspect it's due to td.reset() in other tests resetting the global mocks (which should never be reset—but the global beforeEach should put them back). |
So... For troubleshooting failed tests. Makes a lot of sense. |
By the way, it's related to problems caused by td.reset() detailed here: #520 |
I use testdouble pretty extensively, and for each test run, I'd like to list which modules have been replaced (via
replaceEsm
). I don't see anything relevant in the docs or exported from td.PS Love this lib
The text was updated successfully, but these errors were encountered: