babel-plugin-rewire icon indicating copy to clipboard operation
babel-plugin-rewire copied to clipboard

Support for Reset All would be useful

Open sazzer opened this issue 7 years ago • 4 comments

I like to do a full Reset in the before method of my tests, to make sure that one test can't interfere with another. I've currently got to do this by individually resetting the methods that I might override in the test suite. It would be very useful to be able to do:

setup('Reset Dependencies', function() {
    testSubject.__ResetAllDependencies__();
});

instead and have this iterate over all of the dependencies that could have been rewired.

sazzer avatar Apr 24 '17 11:04 sazzer

Unless i missing something in the documentation, i think this would be really useful. +1 for this.

ricardolpd avatar Apr 25 '17 14:04 ricardolpd

This would help a lot

davidbarton avatar May 31 '17 10:05 davidbarton

https://github.com/speedskater/babel-plugin-rewire/issues/114

dentuzhik avatar Jul 21 '17 11:07 dentuzhik

For anybody who might be as confused about this as I am...

Rewire 1.1.0 adds a global function __rewire_reset_all__() for doing just that. I have used it like so:

afterEeach(function() {
    __rewire_reset_all__();
});

However, if you look at the README on the main page of this repo, you won't find any documentation about that, because you'll see the master branch, which isn't the one that contains 1.1.0 release. That lives in a separate version-1.1.0 branch. Like the 2.x branch, which is also separate from master. Seems that master branch is for maintaining 1.0.0 release... but why maintain it when 1.1.0 is out? That remains a mystery for me.

nene avatar Jan 05 '18 09:01 nene