You are viewing the docs for MSW 2.0. To access the 1.x docs click here.

  • Docs
  • Ecosystem
  • Blog
  • Sponsor
  • 소개
  • 시작하기
  • 철학
  • 비교
  • 제한 사항
  • 마이그레이션
    • 1.x → 2.x
  • 디버깅 실행 매뉴얼
  • FAQ
  • Basics
    • 요청 가로채기
    • 응답 모킹하기
    • WebSocket 이벤트 처리하기
  • Concepts
    • Request namespace
    • Request handler
    • Response resolver
  • Network behavior
    • Describing REST API
    • Describing GraphQL API
    • Describing WebSocket API
  • Integrations
    • Browser integration
    • Node.js integration
    • React Native integration
  • API
    • setupWorker
      • start()
      • stop()
      • use()
      • resetHandlers()
      • restoreHandlers()
      • listHandlers()
    • setupServer
      • listen()
      • close()
      • use()
      • boundary()
      • resetHandlers()
      • restoreHandlers()
      • listHandlers()
    • http
    • graphql
    • ws
    • HttpResponse
    • delay
    • bypass
    • passthrough
    • RequestHandler
    • getResponse
    • Life-cycle events
  • CLI
    • init
  • Best practices
    • Introduction
    • Structuring handlers
    • Network behavior overrides
    • Avoid request assertions
    • Custom request predicate
    • Dynamic mock scenarios
    • Managing the worker
    • Using with TypeScript
  • 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

Introduction

Our mission is to help you describe the network you want. With that in mind, we have prepared a set of best practices you can employ to improve your network descriptions.

Structuring handlers

Manage a large number of request handlers.

Network behavior overrides

Override network behaviors on runtime.

Avoid request assertions

Learn why you should not assert requests directly.

Custom request predicate

Intercept requests by custom criteria.

Dynamic mock scenarios

Apply different network scenarios on runtime.

Managing the worker

Learn how to manage the worker script updates.

Last updated on January 16, 2025

Edit this page on GitHub

Community

  • GitHub
  • Discord
  • Blog

Partners

© 2025 Mock Service Worker

Created with by kettanaito

Library

  • Documentation
  • Branding
  • Blog

Resources

  • Getting started
  • Best practices
  • Examples

Community

  • GitHub
  • Twitter
  • Discord