Open mjackson opened 8 years ago
If it exists, it should reset everything - as in, it should be as if i created a brand-new spy and reassigned it to spy
.
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.