We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GET
POST
DELETE
MSW 설치 및 설정
npm install msw --save-dev
mocks
핸들러 정의
import { rest } from 'msw'; export const handlers = [ rest.get('/api/users', (req, res, ctx) => { return res( ctx.status(200), ctx.json({ users: [{ id: 1, name: '홍길동' }, { id: 2, name: '김철수' }] }) ); }), rest.post('/api/users', (req, res, ctx) => { const newUser = req.body; return res( ctx.status(201), ctx.json(newUser) ); }), ];
서비스 워커 등록
if (process.env.NODE_ENV === 'development') { const { worker } = require('./mocks/browser'); worker.start(); }
테스트 및 검증
public
mocks/handlers
The text was updated successfully, but these errors were encountered:
Hjwoon
No branches or pull requests
🚀 Summary
요구 사항
GET
,POST
,DELETE
등 다양한 HTTP 메소드를 사용하는 API 통신을 가짜 데이터와 함께 시뮬레이션해야 함.개발 방법
MSW 설치 및 설정
mocks
폴더 내에서 핸들러 정의.핸들러 정의
서비스 워커 등록
테스트 및 검증
예상 결과
📝 To Do
public
디렉토리에 설정하고,mocks/handlers
파일에 API 경로와 응답 정의.🏞️ images
The text was updated successfully, but these errors were encountered: