[chore] Vitest 테스트 환경 구축 및 Yarn PnP SDK 최적화#16
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (20)
📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 Walkthrough개요Vitest 기반 테스트 환경 도입을 위해 프로젝트 설정을 구성합니다. 패키지 의존성 추가, Vite 설정 업데이트, 테스트 스크립트 정의, 테스트 환경 초기화 파일 생성 및 Yarn Berry PnP 호환성을 위한 .gitignore 규칙 업데이트를 포함합니다. 변경사항
예상 코드 리뷰 시간🎯 2 (Simple) | ⏱️ ~12 분 제안 라벨
시
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
package.json (1)
12-14: VSCode SDK 초기화 명령을 스크립트로 노출해 두면 온보딩이 더 안전합니다.PR 안내에만 의존하면 누락되기 쉬워서, Line 12~14 근처에 실행용 스크립트를 추가해 두는 편이 좋습니다.
제안 diff
"scripts": { "dev": "vite", "build": "tsc -b && vite build", "lint": "eslint .", "format:check": "prettier --check .", "preview": "vite preview", "prepare": "husky", + "sdk:vscode": "yarn dlx `@yarnpkg/sdks` vscode", "test": "vitest", "test:run": "vitest run" },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@package.json` around lines 12 - 14, Add a package.json script to expose the project's VSCode SDK initialization command so contributors can run it easily during onboarding; for example add a new script key like "vscode:setup" (placed alongside "prepare", "test", "test:run") that runs the same VSCode SDK init command used in your onboarding docs (replace with the actual CLI or local script your project uses, e.g., the project's SDK init CLI or a scripts/init-vscode-sdk.js wrapper).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@package.json`:
- Around line 12-14: Add a package.json script to expose the project's VSCode
SDK initialization command so contributors can run it easily during onboarding;
for example add a new script key like "vscode:setup" (placed alongside
"prepare", "test", "test:run") that runs the same VSCode SDK init command used
in your onboarding docs (replace with the actual CLI or local script your
project uses, e.g., the project's SDK init CLI or a scripts/init-vscode-sdk.js
wrapper).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b5897591-3702-49b9-9463-fedeb568a3a2
⛔ Files ignored due to path filters (20)
.yarn/sdks/eslint/bin/eslint.jsis excluded by!**/.yarn/**.yarn/sdks/eslint/lib/api.jsis excluded by!**/.yarn/**.yarn/sdks/eslint/lib/config-api.jsis excluded by!**/.yarn/**.yarn/sdks/eslint/lib/types/config-api.d.tsis excluded by!**/.yarn/**.yarn/sdks/eslint/lib/types/index.d.tsis excluded by!**/.yarn/**.yarn/sdks/eslint/lib/types/rules.d.tsis excluded by!**/.yarn/**.yarn/sdks/eslint/lib/types/universal.d.tsis excluded by!**/.yarn/**.yarn/sdks/eslint/lib/types/use-at-your-own-risk.d.tsis excluded by!**/.yarn/**.yarn/sdks/eslint/lib/universal.jsis excluded by!**/.yarn/**.yarn/sdks/eslint/lib/unsupported-api.jsis excluded by!**/.yarn/**.yarn/sdks/eslint/package.jsonis excluded by!**/.yarn/**.yarn/sdks/integrations.ymlis excluded by!**/.yarn/**.yarn/sdks/typescript/bin/tscis excluded by!**/.yarn/**.yarn/sdks/typescript/bin/tsserveris excluded by!**/.yarn/**.yarn/sdks/typescript/lib/tsc.jsis excluded by!**/.yarn/**.yarn/sdks/typescript/lib/tsserver.jsis excluded by!**/.yarn/**.yarn/sdks/typescript/lib/tsserverlibrary.jsis excluded by!**/.yarn/**.yarn/sdks/typescript/lib/typescript.jsis excluded by!**/.yarn/**.yarn/sdks/typescript/package.jsonis excluded by!**/.yarn/**yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (5)
.gitignore.vscode/settings.jsonpackage.jsonsrc/test/setup.tsvite.config.ts
6b2cdd3 to
f75ba23
Compare
#️⃣ 관련 이슈
⏰ 작업 시간
💻 작업 내용
vitest, @testing-library/react, happy-dom 등 테스트 관련 의존성 설치
vitest.config.ts 및 src/test/setup.ts 파일 생성을 통한 전역 테스트 설정
개발자 로컬 환경에 종속적인 .yarn/sdks 및 .yarn-cache를 Git 추적에서 제외
에디터(VS Code)에서 타입 체크 및 Prettier가 정상 작동하도록 .vscode/settings.json 공유 설정 유지
확인용 테스트 코드 작성해서 통과 확인해봄
테스트 런타임 환경으로 happy-dom 채택
💡 테스트 코드 및 실행 결과
작업하면서 고민한 부분
문제: Yarn PnP 환경에서 VS Code가 Prettier나 TypeScript를 제대로 인식하지 못해 빨간 줄이 뜨거나 포맷팅이 깨지는 현상이 발생함.
해결:
yarn dlx @yarnpkg/sdks vscode를 통해 프로젝트 내부에 SDK를 생성하고, 해당 경로를.vscode/settings.json에 명시하여 모든 팀원이 동일한 도구 경로를 바라보게 설정함.Git 관리 고민: 로컬 환경마다 달라질 수 있는 SDK 파일(약 400개)이 Git에 올라가는 문제를 발견하여,
git rm --cached를 통해 원격 저장소에서는 삭제하되 로컬에서는 유지되도록 처리함.문제: 기존 jsdom 사용 시 Yarn Berry PnP 환경의 의존성 경로나 peer dependency 문제로 인해 테스트 환경이 불안정해질 가능성이 존재함.
해결: jsdom 대비 가볍고 Vitest와 호환성이 뛰어난 happy-dom을 채택하여 테스트 실행 속도와 안정성을 확보함.
판단 근거: 현재 테스트 범위인 입력값 변경, 버튼 활성/비활성, 파일 업로드 상태, 조건부 렌더링 등 React 컴포넌트 단위 테스트를 수행하기에 happy-dom의 기능으로 충분하다고 판단함. (완전한 브라우저 환경이 필요한 E2E 테스트가 아닌 단위 테스트에 최적화된 선택)
👀 리뷰 포인트
📘 참고 자료
이번 PR이 머지되면 깃허브 상에서
.yarn/sdks폴더가 사라지게 됩니다. 이는 **삭제된 것이 아니라 Git 관리 대상에서 제외(Ignore)**된 거예요!!정상적인 개발 환경 유지를 위해 pull 이후 다음 단계를 꼭! 한 번만 실행해 주세요:
Summary by CodeRabbit
릴리스 노트
Tests
Chores