-
Notifications
You must be signed in to change notification settings - Fork 117
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
Remove spy.reset #144
Comments
If it exists, it should reset everything - as in, it should be as if i created a brand-new spy and reassigned it to |
Agree. Let's just get rid of it. I don't want to encourage people to keep spies around. They should be these quick, easy things you can just create and throw away. |
The main use case I can think of where it's really useful though is when doing require mocking (a la proxyquire) and you pass in a spy, that's then held in the require cache. |
ie, it can't be easily thrown away, so it's helpful to reset its state. |
It looks like proxyquire is using sinon for its spies implementation. Besides, seems like in the case you describe proxyquire would be creating incidental complexity and forcing me to handle it. Feels like a leaky abstraction. |
The meaning of
spy.reset
is ambiguous (see discussion in #138). What exactly does it reset? The call count? The return/thrown values?My vote is to either remove it or make its meaning more clear. If we remove it, the simple upgrade path is to substitute all uses of
spy.reset()
withspy.calls = []
. Super easy.The text was updated successfully, but these errors were encountered: