Closed zelias500 closed 8 years ago
Why are you passing in proxyquireInstance
into tests? If you can create a project that minimally reproduces this I'd be happy to try it. Otherwise I don't see how this could be a proxyquire bug.
Actually, moving the proxyquireInstance
out of the test solved my problem. My thought was to create a new instance inside each test so I could stub out different methods depending on the test, but it's totally possible to do that outside of the test block.
Thanks for the help!
Sounds good! Proxyquire is like require
. It has special semantics and uses the module
module. Passing an instance around between modules is pretty guaranteed to behave strangely, just like passing around require
.
Hi,
I'm having some trouble stubbing out a nested dependency when running my tests using an external script written for npm test purposes. Below is the relevant code:
and the test file:
This code works by itself (e.g.
node test/test.js
) -- proxyquire behaves properly. However, I'm looking to run this test as part of a suite, usingtest-runner.js
(below):Now, proxyquire doesn't seem to properly stub out the API methods I'm looking to replace -- instead, it makes the ajax request that the method normally makes.
The documentation here is a little spotty, so I'm looking for some help. Would really appreciate it!