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: allowMocked when using a callback for the path #1877
fix: allowMocked when using a callback for the path #1877
Conversation
When an Interceptor was created with a comparator for the path, the `matchOrigin` function was comparing the string equivalent of the function instead of evaluating it. I'm not a fan of the fact that the function `matchOrigin` is comparing the pathname, but that's a refactor for another day. Fixes: nock#1867
🎉 This PR is included in version 11.8.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@mastermatt This fix added another bug (or at least unexpected behavior). |
@YaroslavRepeta validating existence of matches must happen before checking for the The function being called multiple times was expected, note my comment about |
@mastermatt But
instead of
I use a function with counter to simulate server what returns success for first N requests only. And this change breaks my code. However I understand that it's not something what this library guarantee. |
But your suggested change would fundamentally change/break how allowed un-mocked requests would work. We must decide if we have any matches first before falling back to un-mocked. For your use case you should be using |
It's not about the whole library, it's about that piece of code:
If we change to:
nothing will happen, except the fact of saving on unneeded extra computation of matches. Actual checking matches is done in another place: But ok, I'll try to use |
When an Interceptor was created with a comparator for the path, the
matchOrigin
function was comparing the string equivalent of the functioninstead of evaluating it.
I'm not a fan of the fact that the function
matchOrigin
is comparing thepathname, but that's a refactor for another day.
Fixes: #1867