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

removeInterceptor with scope as an argument. #1117

Closed
dpc opened this issue Apr 18, 2018 · 5 comments
Closed

removeInterceptor with scope as an argument. #1117

dpc opened this issue Apr 18, 2018 · 5 comments
Labels

Comments

@dpc
Copy link

dpc commented Apr 18, 2018

It's very easy to mistakenly pass a scope to removeInterceptor and not be aware it's wrong.

First the difference between interceptor and scope is not explained at all in the README, as far as I can tell.

Second, after passing scope to removeInterceptor it actually returns true, even though it does not remove a single item. true is returned unconditionally here: https://github.com/node-nock/nock/blob/11f1a25ee88b0328c92070e4749793902907a60d/lib/intercept.js#L219 no matter if there was a single match in the inner loop just above it, or not.

It seems to me that passing a scope should just work, and be handled correctly (by removing all interceptor from the scope).

@adarrra
Copy link

adarrra commented May 3, 2018

I also couldn't understand why 'removeInterceptor' didn't work for me... And then I understood that

var interceptor = nock('http://example.org').get('somePath');
var scope = interceptor.reply(200)

So issue helped. Don't want to look silly but it was not clear from docs for me.

@gr2m
Copy link
Member

gr2m commented May 3, 2018

Thanks Adara for letting us know. We plan to invest some time to improve the documentation soon, so this is timely and valuable input :)

@stale
Copy link

stale bot commented Sep 13, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We try to do our best, but nock is maintained by volunteers and there is only so much we can do at a time. Thank you for your contributions.

@stale stale bot added the stale label Sep 13, 2018
@stale stale bot closed this as completed Sep 20, 2018
@RichardLitt RichardLitt reopened this Sep 20, 2018
@stale stale bot removed the stale label Sep 20, 2018
@stale
Copy link

stale bot commented Dec 20, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We try to do our best, but nock is maintained by volunteers and there is only so much we can do at a time. Thank you for your contributions.

@stale stale bot added the stale label Dec 20, 2018
@stale stale bot closed this as completed Dec 27, 2018
@lock
Copy link

lock bot commented Jan 10, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you!

@lock lock bot locked as resolved and limited conversation to collaborators Jan 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants