-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
createRequire
support & a way to access the mocked require
#265
Comments
If it involves changing the API, probably not. But if you can find a way to make resolving work without API changes, PR welcome. Stubs would still be relative to the module under test or perhaps you'd resolve absolute paths. |
it'd be gross, but |
Ok I think I get it, I think you want your replacement for |
That seems easy, nonbreaking, and in line with a number of userland APIs - as long as nobody was using the stubs object for a module that exports a function. |
The stubs object I'm referring to is the map of module paths to module override values. So you can still override a module that exports a function. So: proxyquire('./foo', () => {module: {}}) That function would in reality receive an argument that exposes a |
Sounds great - maybe it could be sent an object, that for now only contains require, so it can be extended later? |
The package I want to mock uses
createRequire
to require, which proxyquire doesn't proxy yet. To workaround, I tried:But then I found the
require
above can't be the mocked one. I wonder if you can supportcreateRequire
and give us a way to access the mockedrequire
(so that we can mockcreateRequire
to return arequire
with our own properties).Thanks!
The text was updated successfully, but these errors were encountered: