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

nock.removeInterceptor with an Interceptor instance does not remove it from its scope #2353

Open
2 tasks done
mbargiel opened this issue May 17, 2022 · 0 comments · May be fixed by #2355
Open
2 tasks done

nock.removeInterceptor with an Interceptor instance does not remove it from its scope #2353

mbargiel opened this issue May 17, 2022 · 0 comments · May be fixed by #2355
Labels

Comments

@mbargiel
Copy link
Contributor

mbargiel commented May 17, 2022

Please avoid duplicates

Reproducible test case

See example snippet in description.

Nock Version

13.2.4

Node Version

16.13.1

TypeScript Version

No response

What happened?

Removing interceptors through nock.removeInterceptor correctly removes them from pending and active mocks, but does not remove them from their scope's interceptors array. This seems similar to #721 but related to scope.interceptors rather than nock.pendingMocks().

Repro:

const nock = require('nock')
const scope = nock('http://example.com').get('/').reply(200)
console.log('interceptor count in scope:', scope.interceptors.length)
nock.removeInterceptor(scope.interceptors[0])
console.log('interceptor count in scope:', scope.interceptors.length)

Expected logged values:

interceptor count in scope: 1
interceptor count in scope: 0

Actual logged values:

interceptor count in scope: 1
interceptor count in scope: 1

Would you be interested in contributing a fix?

  • yes
@mbargiel mbargiel added the bug label May 17, 2022
@mbargiel mbargiel changed the title nock.removeInterceptor with an Interceptor instance does not remove it from scopes nock.removeInterceptor with an Interceptor instance does not remove it from its scope May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant