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
Support intercepting of require() #68
Comments
I understand the need to intercept You could wrap you code in an |
This is unfortunate, I'm feeling compelled to use jest exactly for this feature. I'm glad to see from #73 that you're revisiting this decision. |
For intercepting require you may want to have a look at proxyquire which does exactly (and only) that. Jest would work as well afaik but is a much larger package. |
@thlorenz do know you if it's possible to combine proxyquire and rewire? Meaning to load a module with injection and get private variables from it? |
I have not used rewire and thus would not know, sorry. |
I've been trying to use rewire with FRP languages such as ramda and experienced an issue/downfall which I'd like to bring up for discussion. This relates to previous tickets which have mentioned having a way of overriding dependencies on initial rewire call. As the isInList caches the function creation with one argument to optimise the call and improve code readability it is excluded in the
__set__
update therefore returning the wrong result until the function is moved into the executed code block (see hacked example).It is a very primitive example but when working on nested promise chains where you have nested levels it becomes cumbersome to test and fix.
Suggested fix would be to allow certain modules to be changed on initialisation;
This would stop your users needing to use other third party modules such as mockery or quire to change required modules on instantiation.
Example file:
Example test:
Hacked example file to work:
The text was updated successfully, but these errors were encountered: