Closed realsuayip closed 12 months ago
Hello @realsuayip ,
This behavior is already documented.
Considering that the following requests are issued by your code:
With your example, this would mean the following responses:
Unless you expect the absolute URL to be issued only once, changing the order of registration would NOT fix this issue as this would mean the following responses:
To properly fix your issue, your regex should exclude the specific URL it shouldn't match.
To come back on your proposal: I understand that, in your use case, you provide only 2 response, one being an absolute match and the other being a regex. It is indeed easy to imagine that we could make a deterministic choice and always chose the absolute match. However this might not be the expected behavior for everyone, moreover we can imagine use case with more than one regex matching the same url. Making it even harder to know what is the expected behavior for the user.
In any case, I am always eager to enhance the documentation to avoid unexpected behavior. Do you have any proposal as to how this could be achieved?
Thanks again
It seems that I have missed the relevant part in documentation. Thanks for the clarification.
Take this example:
In this case, my expected behavior is:
First, match the more specific URL, otherwise fallback to more general URL.
However, the code above ends up creating flaky tests; most of the time, it works, but sometimes it fails when it matches the regex first and not the specific case.
As far as I understand, this can be solved by defining specific matchers before the general ones. And that's fine.
I have two suggestions: