LOGOMock Service Worker
  1. Api
  2. setupServer()
  3. printHandlers()

printHandlers()

Prints the list of currently active request handlers into the stdout of the running process.

Example

1// handlers.js
2import { rest } from 'msw'
3import { setupServer } from 'msw/node'
4
5const server = setupServer(
6 rest.get('/user/:userId', (req, res, ctx) => {
7 return res(ctx.json({ id: req.params.userId }))
8 }),
9)

To list all the active request handlers run the following command:

1server.printHandlers()

Each request handler outputted into the console contains the following information:

  • Request method (GET) and path (/user/:userId).
  • Declaration frame (handlers.js@5:8) you can click to navigate to the place in your code where you declare this handler.