I'm having trouble getting Proxyquire to work with a basic method substitution, and I can't seem to pinpoint the issue.
First, I have a file called lib.js:
module.exports = {
thing: () => {
console.log("thing");
}
};
Then, there's test.js:
const lib = require("./lib");
module.exports = () => {
lib.thing();
};
Next, I tried to stub the dependency and replace 'thing' with another function like so:
const proxyquire = require("proxyquire");
const libStub = {};
const test = proxyquire("./test", {"lib": libStub});
test();
libStub.thing = () => {
console.log("replaced");
};
test();
Unfortunately, even after replacing 'thing' with "replaced", the test still logs out "thing" both times instead of the expected "replaced" on the second call. Any insight or assistance on this matter would be greatly appreciated.