i-like-robots / rewireify

Rewireify is a port of Rewire for Browserify that adds setter and getter methods to each module so that their behaviour can be modified for better unit testing.
https://www.npmjs.com/package/rewireify
Other
59 stars 10 forks source link

Test objects for extensibility #15

Closed shebson closed 9 years ago

shebson commented 9 years ago

Attempting to extend a non-extensible object results in a type error. This PR checks that module.exports is extensible before adding set and get.

i-like-robots commented 9 years ago

Thanks for taking the time to submit this and sorry for slow reply, not sure how I didn't see this before...

Have you come across this case where this addition has helped you? I can't think of a case where module.exports would become sealed or immutable - is this just being careful?

shebson commented 9 years ago

This came up for me in a React app. React elements are frozen at creation, and I imagine this would also be an issue for people using ImmutableJS.

i-like-robots commented 9 years ago

Good to know, thanks!