Split internal module registry from main module registry #1572
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Here's a possible fix for #1571.
When the
mkdirp
module is first required, it's required fromjest-utils
, which is required from jasmine-check.js, which is required usingrequireInternalModule
from jest-jasmine2/index.js. Because requiring internal modules and requiring "normal" modules (e.g. in a test or within your own code) use the same module registry, whenmkdirp
is required by the app code, Jest already has required it (as an internal module), and thus it doesn't try to require it again and just returns it from the module registry, meaning it doesn't pick up thefs
mock from our test file.This PR splits the module registries so that conflict doesn't happen, and we can reliably use internal modules within Jest without conflicting with the test environment.
P.S. Sorry for being annoying earlier @cpojer...this is my attempt at redemption.