-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Broken access to Node.js modules cache #6725
Comments
Duplicate of #5741 |
It's by design and Jest provides workarounds for that: |
How they're supposed to work for dependencies?
Why agreed design is to replace known public API with custom (Jest specific) one? As I understand the goal is to isolate environment for tests, and from what I see same could be achieved maintaining same API contract, isn't it? |
Populating So - while it's easy enough to populate |
Well that'll be just another bug on a side of Jest, so it's obvious you'll receive bug reports :) Other issue I observed is that popular (test engine agnostic) I know that Jest brings it's own custom API to achieve module mocks, but as I looked it's quite limited and not as flexible as what can be achieved with public Node.js endpoints (and tools as What's even more controversial is that it implies quite controversial vendor lock-in, as once we agree to rely on those custom Jest endpoints, it becomes harder to switch to other solution. |
Feel free to send a PR for it. With No guarantees it'll be merged though - what we have today covers close to all use cases already, so any change is potentially disruptive |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
require.cache
is broken in modules tested byJest
. This is a public, documented feature, while rarely, it's occasionally used by some modules (e.g. https://github.com/sindresorhus/meow/blob/258659a6e4cf102ef09a7c27efcee1e953808725/index.js#L14)To Reproduce
Created two modules
a.js
as empty file, andb.js
with content as:When run through
jest
this module exportsundefined
Expected behavior
require.cache
should not be affected, e.g. above module when run directly via Node.js will log module instance.Link to repl
https://repl.it/@medikoo/broken-modules-cache-access
Env info
Paste the results here:
System: OS: macOS High Sierra 10.13.5 CPU: x64 Intel(R) Core(TM) i7-2760QM CPU @ 2.40GHz Binaries: Node: 10.7.0 - /usr/local/bin/node Yarn: 1.7.0 - /usr/local/bin/yarn npm: 6.1.0 - /usr/local/bin/npm npmPackages: jest: ^23.4.1 => 23.4.1
The text was updated successfully, but these errors were encountered: