-
-
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
Missing require.main inside of scripts loaded inside of isolateModules callback #9470
Comments
See #5618 for some info on why this algorithm was chosen Logic for This breaks due to the way I'm not sure how to best untangle this so Would you be able to dig a bit into this an potentially provide a PR? //cc @rogeliog in case you have any ideas |
Looks like the same problem will exist with |
@jeysal yeah, agreed. The current approach is a bit too naive |
Can I help with this? Or does #10610 fix this? |
Yes please! #10610 does not fix it since You solved the issue of "first require might not be test file" in #10610, so that should not be an issue |
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
If some script would be required inside of
jest.isolateModules
callback thenrequire.main
would benull
inside of it. Thank is not how NodeJS works and not how the same script would work if it would be loaded outside ofjest.isolateModules
To Reproduce
Steps to reproduce the behavior:
Consider a super simple script that would just use
require.main.require
index.js
And a test for it
Expected behavior
The test should pass. And it will, if only
2
and4
lines ofindex.test.js
that wraprequire
inside ofjest.isolateModules
would be removedLink to repl or repo (highly encouraged)
https://github.com/Alexsey/jest-require-main-bug
envinfo
The text was updated successfully, but these errors were encountered: