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


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


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

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


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.
  • REPL preview link ( for REST API requests.