-
-
Notifications
You must be signed in to change notification settings - Fork 733
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
fix: make interceptors work in any order even when filteringScope #1819
Conversation
@paulmelnikow Wanna review this PR? Or invite someone who would? |
@salmanm thanks for taking this on. The As noted in the original issue, the bug is that the function returns early before it has a chance to set My suggestion is to replace lines 153-169 with this: const { filteringScope } = interceptors[0].scope.scopeOptions
// If scope filtering function is defined and returns a truthy value then
// we have to treat this as a match.
if (filteringScope && filteringScope(basePath)) {
debug('found matching scope interceptor')
// Keep the filtered scope (its key) to signal the rest of the module
// that this wasn't an exact but filtered match.
interceptors.forEach(ic => {
ic.__nock_filteredScope = key
})
return interceptors
} Things to note: |
Ok those two clarifications changes things. I didn't know that they're guaranteed to have the same scope. I'll change it to you suggestion of a sub loop to set the and yes, I agree we should get rid of those magic attribs, but perhaps that's a bigger refactor and can be done separate from this PR? |
Aye pushed the suggested changes. 👍 |
@mastermatt Would you like to take another look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me.
Can we move this forward please? Or let me know if there are any changes. Thanks @paulmelnikow. |
🎉 This PR is included in version 11.7.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fixed #1818