Closed tiagopadua-hp closed 8 years ago
Proxyquire will try to load the original module in order to fill the unstubbed keys. The way to prevent that is with the noCallThru feature. The string key with @
needs to be part of a module stub (e.g. './b'
, not the stub object itself. Instead, you can enable that feature like this:
https://github.com/thlorenz/proxyquire#all-together-now
You can't use the property shortcut because you're exporting a string from your module.
Hello,
I'm not really sure if this is a problem or it's by design, but it's something causing me problems to write my unit tests. Also, I have not found any documentation nor posts about this in any forums (googled for hours).
Well, let's give an example. To simplify things, say my project has the following structure:
/a.js
/b.js
/tests/test.js
I want to test the file a.js and mock its dependency (b.js).
But when I run the tests/test.js, the original file b.js is being executed, even when I mocked it with proxyquire. The result is the following:
In the project I got, instead of a console.log, the code of "b.js" actually connects automatically to a Redis server, and this is giving me troubles.
I tried to add
, '@noCallThru': true
but same result.Is there any way to block the b.js from running at all?