Conversation
- RSC에서 동작 여부 확인 필요
| }>) { | ||
| useEffect(() => { | ||
| (async () => { | ||
| if (typeof window !== "undefined" && process.env.NEXT_MOCK_SERVER) { |
There was a problem hiding this comment.
여기서 useEffect를 사용해서 mockServer를 클라이언트에서 마운트되고 시작하게 만든거군욥
There was a problem hiding this comment.
저도 검색해서 사람들이 사용한 방식 채용한겁니다. env 값으로 msw를 쓸지말지 정하는 방식은 좋아보이더라고요.
HamInKyou
left a comment
There was a problem hiding this comment.
잘봤습니다! 설정 관련해서는 아직 잘 모르다보니 이해하고 넘어가는 식으로 읽어보았어요
| @@ -0,0 +1,14 @@ | |||
| import { http, HttpResponse } from "msw"; | |||
|
|
|||
| const signIn = [ | |||
There was a problem hiding this comment.
signIn -> sign으로 바꿔야할 것 같아욥
There was a problem hiding this comment.
이 부분은 로그인 관련 테스트 코드 작업하면서 수정해놓겠습니다. 현재 PR의 중점은 MSW 기본 세팅위주로 잡은지라 수정될 여지가 많아서요.
| import { http, HttpResponse } from "msw"; | ||
|
|
||
| const signIn = [ | ||
| http.post(`${process.env.NEXT_PUBLIC_API_KEY}/sign-in`, () => { |
There was a problem hiding this comment.
첫번째 매개변수 통해 넘겨온 api를 mock이 탈취해서 HttpResponse.json 형태로 돌려주는 꼴 맞나요?
There was a problem hiding this comment.
네 맞습니다. 리턴 방식은 다양하게 바꿔줄 수 있습니다만, 임시로 공식문서에서 제안한 �리턴값을 넣어둔 상태입니다.
There was a problem hiding this comment.
여기서 모든 mock handler들이 다 모이는거구요?
There was a problem hiding this comment.
네네 맞습니다. node와 브라우저간 핸들러 다루는 함수(setupWorker)가 달라 이 둘은 나눠집니다.
There was a problem hiding this comment.
mock handler들을 여기서 다 갖고와서 목업 서버를 셋팅하는거구요
There was a problem hiding this comment.
요거는 외부의 공식 문서 같은거를 들고와서 그대로 사용하신 그런 느낌인것 같아요 맞아요?
There was a problem hiding this comment.
정확히는 MSW 공식문서 Draft PR 상태로 남아있는
mswjs/examples#101
이 코드를 참조했습니다.
Changes
Reason for change
Detailed Description
mention
@osydoo @HamInKyou
Resolves: #
See also: #