You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a rather unfortunate behavior of MSW: mswjs/msw#814
When there are two handlers specified like this:
rest.get(`${API_URL}/blog-categories/:id`,resolver)// first one with path parameterrest.get(`${API_URL}/blog-categories/count`,resolver)// second one with static path
Then a request to /blog-categories/count will return the response defined in /blog-categories/:id because that one is matched first.
Since orval generates the mock definitions in an order that is incompatible with the "desired" behaviour, the mock will always return the wrong response.
What were you expecting to happen?
I expect it to resolve the correct mock handler.
A quick fix to this problem could be to sort the mock definitions:
Any handler that has path parameter should be after all the handlers with static paths. This way the above scenario would never apply.
Thank you!
What versions are you using?
Package Version: 6.10.2
The text was updated successfully, but these errors were encountered:
What are the steps to reproduce this issue?
This is a rather unfortunate behavior of MSW: mswjs/msw#814
When there are two handlers specified like this:
Then a request to
/blog-categories/count
will return the response defined in/blog-categories/:id
because that one is matched first.Since orval generates the mock definitions in an order that is incompatible with the "desired" behaviour, the mock will always return the wrong response.
What were you expecting to happen?
I expect it to resolve the correct mock handler.
A quick fix to this problem could be to sort the mock definitions:
Any handler that has path parameter should be after all the handlers with static paths. This way the above scenario would never apply.
Thank you!
What versions are you using?
Package Version: 6.10.2
The text was updated successfully, but these errors were encountered: