thlorenz / proxyquireify

browserify >= v2 version of proxyquire. Mocks out browserify's require to allow stubbing out dependencies while testing.
MIT License
151 stars 24 forks source link

duplicate modules in presence of proxyquireify #54

Closed remster closed 8 years ago

remster commented 8 years ago

I am having a mocha test suite with two mocha files. They go about doing different things. One of them uses proxyquireify to mock out the http module (and thus get rid of the external calls from the tests). whenever i change var routeModule = require("../scripts/ui/mapRoute.js"); to var routeModule = proxyquire("../scripts/ui/mapRoute.js", stubs);

ALL of my source modules get loaded/evaluated twice - which is of course undesired. Is it plausible wrt design? Is it a surprise? Shall i supply evidence? (evidence is hard to supply in my case, so i don't want to waste time if this is a known issue).

bendrucker commented 8 years ago

This is expected behavior. Proxyquireify manipulates the cache. Depending on how and where you require your files you can get things that are re-evaluated.