본문으로 건너뛰기
Skillpedia
테스트75k · #2941

mock-best-practices

하는 일

이 스킬은 외부 코드 부분을 대신하는 모의 객체(mock)를 테스트 파일이 어떻게 쓰는지 검토합니다. 단순히 통과하는 것이 아니라 실제 문제를 잡는 테스트를 원하는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓테스트 파일이 모의 객체를 어떻게 쓰는지 검토해 달라고 요청할 때.
  • ✓테스트는 통과하지만 실제 앱이 깨질 때, 너무 많이 모의 처리했다고 의심될 때.
  • ✓새 테스트를 쓰면서 무엇을 모의 처리하고 무엇을 실제로 둘지 안내가 필요할 때.

스킬 링크

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/mock-best-practices/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/mock-best-practices/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“테스트는 통과하는데 앱은 여전히 깨져요. 내가 너무 많은 것을 모의 처리하고 있는지 확인해 주실 수 있나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트가 테스트 파일을 읽고, 비즈니스 로직을 숨기는 모의 객체, 누락된 정리, 내부 세부 사항을 확인하는 테스트를 찾습니다. 그다음 불필요한 모의 객체를 제거하고 적절한 수준에서 모의 처리하도록 제안합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Follow mocking best practices

Proper mocking isolates units under test while keeping tests realistic—over-mocking creates false confidence when tests pass but production breaks.

Quick Reference

  • Mock external dependencies (APIs, databases, file system), not business logic
  • Always clean up mocks with jest.restoreAllMocks() in afterEach
  • Use MSW for realistic API mocking without coupling to implementation
  • Test behavior and outputs, not internal implementation details

Check

Review this test file for mocking patterns, checking for over-mocking, missing mock cleanup, and proper mock implementation.

Fix

Improve mocking strategy by removing unnecessary mocks, adding proper cleanup, and mocking at the right level of abstraction.

Explain

Explain mocking best practices including when to mock, what to mock, and common mocking pitfalls.

Code Review

Review tests, CI workflows, and enforcement points related to Follow mocking best practices. Flag exact gaps where the rule is not automatically verified or where failures do not block regressions.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/testing/mock-best-practices

자주 묻는 질문

무엇을 모의 처리해야 하나요?

API, 데이터베이스, 파일 시스템 같은 외부 의존성은 모의 처리하고, 비즈니스 로직은 모의 처리하지 말라고 스킬은 말합니다.

MSW는 무엇인가요?

코드가 API를 호출하는 방식에 의존하지 않는 현실적인 API 모의 처리를 위한 도구입니다.

모의 객체를 왜 정리해야 하나요?

테스트 사이에 남은 모의 객체는 결과를 바꾸고, 실패의 원인을 찾기 어렵게 만들 수 있다고 스킬은 설명합니다.

상세 정보

작성자의 원본 설명

Use when reviewing CI coverage, automated checks, or test strategy related to Follow mocking best practices. Focus on whether the rule is continuously verified, not just documented.

repo: thedaviddias/Front-End-Checklist

인기도

GitHub 스타
75k
순위
#2941
라이선스
MIT
업데이트
2026. 10. 31.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬