passthrough
Use the req.passthrough
method of the intercepted request to explicitly state that you wish for the library to bypass this request (perform as-is).
Since version 0.40.0, returning
undefined
/null
from a response resolver will consider the intercepted request as unhandled.1import { rest } from 'msw'23export const handlers = [4 rest.post('/user', (req, res, ctx) => {5 // Perform the intercepted "POST /user" request as-is6 // if its query string has the "id" parameter.7 if (req.url.searchParams.has('id')) {8 return req.passthrough()9 }1011 // Otherwise, return a mocked "text/plain" response.12 return res(ctx.text('hello'))13 })14]