fix: make interceptors work in any order even when filteringScope#1819
fix: make interceptors work in any order even when filteringScope#1819paulmelnikow merged 3 commits intonock:masterfrom
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? |
|
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