Skip to content

support selecting interceptors #2072

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

You must be logged in to vote

Hi, @juliusmarminge. That's a good question!

MSW promotes the philosophy that you can describe the network regardless of the implementation details of that network. Providing a precise interceptor is not something we encourage directly because you want consistent behavior no matter how the request is made.

If you absolutely must narrow down the interception, you can do that by creating your own setupServer function using the public API:

import { XMLHttpRequestInterceptor } from '@mswjs/interceptors/XMLHttpRequest'
import { SetupServerCommonApi } from 'msw/node'

class SetupXMLHttpRequestServerApi extends SetupServerCommonApi {
  constructor(...handlers) {
    super([XMLHttpRequestInterceptor

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kettanaito
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #2071 on March 06, 2024 22:49.