Skip to content
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

[Bug]: Custom resolver cannot intercept import fs #12649

Closed
ChocolateLoverRaj opened this issue Apr 7, 2022 · 3 comments · Fixed by #12654
Closed

[Bug]: Custom resolver cannot intercept import fs #12649

ChocolateLoverRaj opened this issue Apr 7, 2022 · 3 comments · Fixed by #12654

Comments

@ChocolateLoverRaj
Copy link
Contributor

Version

27.5.1

Steps to reproduce

  1. Clone my repo at https://github.com/ChocolateLoverRaj/jest-bug-2
  2. Install dependencies
  3. Run npm test
  4. Look at output for fs and never logs

(never) Is to show that the resolver is getting npm packages, but not the fs module.

Expected behavior

I expect to see never and fs

Actual behavior

I see never, but not fs

Additional context

This bug is affecting the development of https://github.com/ChocolateLoverRaj/mock-deep. In that repo, I'm trying to actually mock files that could be ESM.

Environment

System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  Binaries:
    Node: 16.13.0 - C:\Program Files (x86)\Nodist\bin\node.EXE
    npm: 8.1.0 - C:\Program Files (x86)\Nodist\bin\npm.EXE
  npmPackages:
    jest: ^27.0.6 => 27.5.1
@SimenB
Copy link
Member

SimenB commented Apr 8, 2022

Yeah, we don't call custom resolvers on node core modules: https://github.com/facebook/jest/blob/a5f1ef43981b7426d61bcd7cbc59a79f548c075a/packages/jest-resolve/src/resolver.ts#L221-L223 & https://github.com/facebook/jest/blob/a5f1ef43981b7426d61bcd7cbc59a79f548c075a/packages/jest-resolve/src/resolver.ts#L295-L297, added in #11817. I guess we should only skip calling the resolver if it's our own, and not custom resolvers. Wanna send a PR?

@ChocolateLoverRaj
Copy link
Contributor Author

Wanna send a PR?

I will try

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants