speedskater / babel-plugin-rewire

A babel plugin adding the ability to rewire module dependencies. This enables to mock modules for testing purposes.
843 stars 90 forks source link

Support for Reset All would be useful #188

Open sazzer opened 7 years ago

sazzer commented 7 years ago

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.

ricardolpd commented 7 years ago

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

davidbarton commented 7 years ago

This would help a lot

dentuzhik commented 6 years ago

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

nene commented 6 years ago

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.