thlorenz / proxyquireify

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

Cannot stub module with falsy value #48

Closed bendrucker closed 8 years ago

bendrucker commented 8 years ago

Migrating from #32 / @kgryte:

So the issue I reported over at https://github.com/bendrucker/proxyquire-universal/issues/18 actually seems to be related to this issue. When I set a stub to false, the stub is ignored, but, when I set the stub to a truthy value, the stub is used, even in the browser.

I am guessing this has to do with "simulating the absence of modules", but I was under the impression that setting a stub to null meant that the stub was ignored, not simply a falsey value.

Note: I am using proxyquirify@3.0.1.

kgryte commented 8 years ago

Re: versioning. I am not convinced that implicit behavior should be considered a contract. What is explicit is that proxyquire documents using null, and thus, the proposed contract is that, in order to mock the absence of a module, use null, not more generally a falsey value. If users were relying on undocumented behavior, they do so at their own risk. I would argue that patching this behavior is more a bug fix than a major release.

bendrucker commented 8 years ago

Can't be too careful when it comes to breaking people's builds

kgryte commented 8 years ago

By that same criterion, every change to a piece of code is a major version bump, including bug fixes, regardless of whether the code is used for testing or not.

kgryte commented 8 years ago

Regardless, thanks for your responses and efforts!

bendrucker commented 8 years ago

Yup, commits coming!