Skip to content
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

Open
mjackson opened this issue Jul 27, 2016 · 5 comments
Open

Remove spy.reset #144

mjackson opened this issue Jul 27, 2016 · 5 comments

Comments

@mjackson
Copy link
Owner

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() with spy.calls = []. Super easy.

@ljharb
Copy link
Collaborator

ljharb commented Jul 27, 2016

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.

@mjackson
Copy link
Owner Author

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.

@ljharb
Copy link
Collaborator

ljharb commented Jul 27, 2016

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.

@ljharb
Copy link
Collaborator

ljharb commented Jul 27, 2016

ie, it can't be easily thrown away, so it's helpful to reset its state.

@mjackson
Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants