-
-
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
Manual user mocks not working with custom resolver #4427
Comments
cc @midzelis |
I'll take a look. Could be a few days before I have something. |
I have a fix. Just adding a test, and then will create PR |
Thanks for caring @midzelis! |
Sorry to comment on an old issue, but i'm having this problem. Is there an example of a simple resolver that does not have this problem? custom resolver: const { NodeJsInputFileSystem, CachedInputFileSystem, ResolverFactory } = require("enhanced-resolve");
const resolver = ResolverFactory.createResolver({
fileSystem: new CachedInputFileSystem(new NodeJsInputFileSystem(), 4000),
useSyncFileSystemCalls: true,
// add src to mainFields so we don't need to build local packages before testing
mainFields: ['src', 'main']
});
module.exports = function(value, options) {
return resolver.resolveSync({}, options.basedir, value);
}; test snippet
error |
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. |
Do you want to request a feature or report a bug?
Bug 🐞
What is the current behavior?
Given I have this jest config:
And a module
<rootDir>/index.js
And a manual mock available in
<rootDir>/__mocks__/index.js
And a spec file mocking the
<rootDir>/index.js
moduleThen I expect the mocked module to be loaded in other modules and my spec
BUT the original module is still being loaded
When I remove the resolver option in my jest config
Then everything works as expected
If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can
yarn install
andyarn test
.https://github.com/Xiphe/jest-custom-resolver-with-mocks
What is the expected behavior?
When I use
jest.mock
to mock a user module fileThen I expect the mocked module to be loaded
Even If I use a custom resolver
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
Minimal jest config to reproduce this error:
customResolver.js
Versions
The text was updated successfully, but these errors were encountered: