Skip to content

How are multiple handler matches supposed to behave? #965

Answered by kettanaito
RyanClementsHax asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, @RyanClementsHax. Thank you for raising this!

We do have the Request matching section but it indeed misses to mention how the library handles the request handler lookup and what will happen when a request matches multiple handlers.

My question is then, is this behavior intended or an accident of implementation details?

This behavior is not an incident, it was always intended. Allow me to clarify it below.

  • When a request matches multiple handlers, MSW will use the first handler that produces a mocked response.

const result = await handler.run(request, resolutionContext)
if (result === null || result.handler.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@RyanClementsHax
Comment options

@kettanaito
Comment options

Answer selected by RyanClementsHax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants