You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The HasteModuleLoader currently maintains a sort-of cache of which modules to mock / not mock in _configShouldMockModuleNames. The cache is indexed by module name, however when a module is included using a relative path, this path is used instead. When requiring a module, the mocking system calls Loader.prototype._shouldMock() which checks (amongst others) this cache, and based on this result a mock or the actual implementation is returned.
Problem:
We are using react-bootstrap which in turn uses uncontrollable which includes a module './utils' in its createUncontrollable.js. Let's call this externalUtils for clarity.
We also have our own utils module which is also included as './utils' in some other modules. Let's call this internalUtils for clarity.
Our tests should mock our internalUtils but not the externalUtils. Depending on the order of which both requires pass through the HasteLoader, either both of them are mocked or both return the real implementation.
A suggested solution would be to use the realPath, which is resolved later in the method as index for the cache.
The text was updated successfully, but these errors were encountered:
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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
The HasteModuleLoader currently maintains a sort-of cache of which modules to mock / not mock in _configShouldMockModuleNames. The cache is indexed by module name, however when a module is included using a relative path, this path is used instead. When requiring a module, the mocking system calls Loader.prototype._shouldMock() which checks (amongst others) this cache, and based on this result a mock or the actual implementation is returned.
Problem:
We are using react-bootstrap which in turn uses uncontrollable which includes a module './utils' in its createUncontrollable.js. Let's call this externalUtils for clarity.
We also have our own utils module which is also included as './utils' in some other modules. Let's call this internalUtils for clarity.
Our tests should mock our internalUtils but not the externalUtils. Depending on the order of which both requires pass through the HasteLoader, either both of them are mocked or both return the real implementation.
A suggested solution would be to use the realPath, which is resolved later in the method as index for the cache.
The text was updated successfully, but these errors were encountered: