-
-
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
require.main is undefined ...when resetModules=true? (maybe) #10625
Comments
@SimenB I'd like to take this up! |
Go for it @flozender 🙂 |
@SimenB However, we lookup |
Yes 👍 |
I was able to get a true reproduction: https://github.com/jsg2021/jest-require-main-issue |
These scenarios should probably be added to the test cases in this PR. There's two test cases (direct and indirect) and two ways to replicate it: Call jest.resetModule() or enable the flag. All should pass. |
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.main
is undefined during tests. My tests were passing in 26.4.2, but failed today's weekly tests. No changes in my project other than new jest version. See some discussion in #10621 After some digging this seems related to the settingresetModules: true
. I cannot find it in my original project, but setting it to true causes the code below to fail the same way it does on codesandbox (note: codesandbox is reproducing the failure just like my project is...) Downloading the codesandbox and running it locally, it passes without changes... adding that config makes it fail.To Reproduce
Steps to reproduce the behavior:
index.js:
index.test.js:
Expected behavior
require.main
is defined, with (ideally) the test file module. eg*.spec.js
/*.test.js
/etc.Link to repl or repo (highly encouraged)
https://codesandbox.io/s/gifted-sara-x25fr
https://github.com/flozender/jest-resetModules
envinfo
The text was updated successfully, but these errors were encountered: