-
-
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
Does not work with requireindex #2017
Comments
Not much code here. I may be able to debug myself: |
Here is the reason: This line always is Because
Possibly related to #281 |
Manually adding |
We don't support this feature consciously in our require implementation. In the applications we create we would like to be able to statically analyze the dependency tree. Custom module resolution algorithms make this more complicated and require custom tooling. It also breaks |
@cpojer Most of the time this is used before using a simple require to check against file extension. How adding the supported extensions to require object can breaks jest ? Should we understand that dynamic require isn't supported by jest ? The more you use jest with node, the more it get annoying, and your answer is definitly not a valid one for the reported issue |
You are right, it isn't supported the way you expect. Jest has its own require implementation and we don't support all kinds of things that node.js supports. If Jest doesn't work for you, please feel free to use a different test runner or send us a PR that adds the feature you need – then we can discuss appropriate implementations :) |
Hmm it feels to me like a huge problem if jest does not even support all features Node.js require supports. So there are no plans to at least support all nodejs require ways? |
As said previously, feel free to work on a PR that adds Note that if we add this, it is possible that we'll break |
Thanks for the heads up @cpojer if I get really ambitious I'll look into this. Frankly I think the following would unblock many of us: Here in https://github.com/facebook/jest/blob/master/packages/jest-runtime/src/index.js#L663: moduleRequire.extensions = Object.create(null); Replacing that with: moduleRequire.extensions = Object.create(null);
moduleRequire.extensions['.js'] = function() {} Not sure what it would break though :) |
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?
requireindex does not work with jest
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal repository on GitHub that we can
npm install
andnpm test
.What is the expected behavior?
requireindex
should workRun Jest again with
--debug
and provide the full configuration it prints. Please mention your node and npm version and operating system.The text was updated successfully, but these errors were encountered: