-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow all rewires to be reverted via rewire.reset() #71
Comments
If you want to bring your module back to the initial state, I think it's the best to just |
Fair enough. I'll close this. |
I also would love to have a global |
I would like to use it within |
When testing in mocha, it would be nice to have a way to reset all of the injections that have been setup via
__set__
. Maybe something like this:The motivation behind this is that we ran into an issue where specs would break when run solo, but not when run together, and part of the problem was that
__set__
is not reverted after a single test run. We are aware of how you can manually revert by storing a reference to the function returned by__set__
and calling it after the test, but the approach mentioned above would make it a lot less error prone.I took a crack at trying to implement this, but I lost my way when I dug in and realized we are using eval of an IIFE function to define
__set__
. I couldn't think of a good way of making__set__
aware of some context in the rewire module where the revert functions could be stored such thatreset
could just invoke all those reverts. Any tips on how we might achieve this?The text was updated successfully, but these errors were encountered: