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

Error when using a function as the stub for a module with PhantomJS + strict mode #44

Closed robertknight closed 8 years ago

robertknight commented 8 years ago

PhantomJS 1.9.x has a bug where the arguments and caller properties are incorrectly returned by getOwnPropertyNames() as members of strict-mode functions but accessing them results in a TypeError.

As a result, attempting to stub a module whose original module.exports is a strict-mode function will result in an error unless call-through to the original module is disabled.

I think it makes sense to patch this in https://github.com/bendrucker/phantom-ownpropertynames but it might be worth adding a check in Proxyquireify's prelude to warn if running under PhantomJS 1.9 which is still in widespread use?

bendrucker commented 8 years ago

I think it's best to address this with the shim and not pollute proxyquire with that info.