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

Add __restore__ method #1

Closed i-like-robots closed 10 years ago

i-like-robots commented 10 years ago

Values modified by __set__ should also be easily restored to their initial value.

sslash commented 10 years ago

Are there any plans to support this in the nearest future?

i-like-robots commented 10 years ago

I'm still unsure about it because it's so simple to do anyway:

var original = myModule.__get__("varName");
myModule.__set__("varName", doTheThings);

...

myModule.__set__("varName", original);

By maybe because it is slightly more convenient. Of course I'm open to contributions!