- Introduction
- Getting started
- Philosophy
- Comparison
- Limitations
- Debugging runbook
- FAQ
- Basics
- Concepts
- Network behavior
- Integrations
- API
- CLI
- Best practices
- Recipes
- Cookies
- Query parameters
- Response patching
- Polling
- Streaming
- Network errors
- File uploads
- Responding with binary
- Custom worker script location
- Global response delay
- GraphQL query batching
- Higher-order resolver
- Keeping mocks in sync
- Merging Service Workers
- Mock GraphQL schema
- Using CDN
- Using custom "homepage" property
- Using local HTTPS
use()
Prepend request handlers to the current server instance.
Call signature
import { http } from 'msw'
import { setupServer } from 'msw/node'
const server = setupServer()
server.use(http.get('/resource', resolver), http.post('/resource', resolver))
The prepended request handlers persist on the server instance as long as the current Node.js runtime exists.