The package I want to mock uses createRequire to require, which proxyquire doesn't proxy yet. To workaround, I tried:
proxyquire('./example', {
module: {
createRequire: (filename) => Object.assign((id) => require(id), {
// ...some other stuff like `resolve`
}),
'@global': true,
},
// ... stubs I use
});
But then I found the require above can't be the mocked one. I wonder if you can support createRequire and give us a way to access the mocked require (so that we can mock createRequire to return a require with our own properties).
Thanks!
The package I want to mock uses
createRequireto require, which proxyquire doesn't proxy yet. To workaround, I tried:But then I found the
requireabove can't be the mocked one. I wonder if you can supportcreateRequireand give us a way to access the mockedrequire(so that we can mockcreateRequireto return arequirewith our own properties).Thanks!