Skip to content

MSW 2: Mock interdependent requests #2066

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

You must be logged in to vote

Hi, @kr8n3r.

Since you want to mock responses to those requests (which is implied by the Nock example you posted), neither passthrough() nor bypass() should be used. Those APIs are for letting MSW ignore the request completely (passthrough) or perform the intercepted request as-is without causing it to go through the handler again, causing an infinite loop (bypass).

Here's that Nock example written using MSW request handlers:

import { http, HttpResponse } from 'msw'
import { setupServer } from 'msw/node'

const server = setupServer(...happyPathHandlers)

// Don't forget to start and close the server
// in the beforeAll/afterAll hooks!

it('should iterate over all pages to gather resources', 

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
None yet
2 participants