1. msw 라이브러리 설치

    $ yarn add msw --save-dev
    
  2. src 폴더 밑에 mocks 폴더 생성

  3. mocks 폴더에 broswer.js, handler.js, index.js, server.js 생성

  4. msw init 명령어 실행

    $ npx msw init public/ --save
    

    public 폴더에 mockServiceWorker.js 파일 생성 확인

    package.json 에 “workerDirectory”: “public” 에 자동으로 설정 됐는지 확인

  5. 브라우저 콘솔 확인

    Untitled

참고: https://github.com/vercel/next.js/tree/canary/examples/with-msw