This teaches you to write tests the way users actually interact with your app, not by poking at internal state. It's built around React Testing Library and Vitest, with a clear hierarchy: use getByRole first, getByLabelText for forms, and only reach for getByTestId when nothing else works. The guide hammers on userEvent over fireEvent, waiting with findBy instead of arbitrary timeouts, and keeping toBeInTheDocument even though getBy already throws, because it signals intent to whoever reads your test later. Includes MSW setup templates and a solid list of mistakes people actually make, like querying with container.querySelector or wrapping everything in act.

skills.sh installs
413
GitHub stars
4
last updated
Aug 21, 2026

Install

$ npx -y skills add dalestudy/skills --skill testing --agent claude-code

Installs into .claude/skills of the current project.

Files

Testing Library

React Testing Library 기반 테스트 작성 모범 관례 및 안티패턴 회피 가이드.

핵심 원칙

Testing Library의 철학: 사용자가 사용하는 방식대로 테스트하라

  1. 접근성 기반 쿼리 우선 - 실제 사용자가 요소를 찾는 방식 사용
  2. 구현 세부사항 테스트 금지 - 컴포넌트 내부 상태/메서드 직접 접근 지양
  3. 실제 사용자 행동 시뮬레이션 - userEvent 사용, fireEvent 지양
  4. 비동기 처리 명시적 대기 - waitFor, findBy 활용

쿼리 우선순위

Testing Library는 다양한 쿼리를 제공하지만, 접근성과 사용자 경험을 반영하는 순서로 사용해야 함.

권장 쿼리 순서 (높음 → 낮음)

  1. getByRole (최우선) - 스크린 리더가 인식하는 방식
  2. getByLabelText - 폼 요소 (label과 연결된 input)
  3. getByPlaceholderText - placeholder가 명확한 경우
  4. getByText - 텍스트 콘텐츠로 검색
  5. getByDisplayValue - 현재 입력된 값으로 검색 (폼 요소)
  6. getByAltText - 이미지 alt 속성
  7. getByTitle - title 속성 (tooltip 등)
  8. getByTestId (최후 수단) - 다른 방법이 불가능할 때만 사용

상세 가이드: references/query-priority.md

사용자 상호작용 테스트

userEvent 사용 (권장)

import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

test('사용자가 폼을 제출할 수 있다', async () => {
  const user = userEvent.setup();
  render(<LoginForm />);

Sponsors

Details

Repository
github.com/dalestudy/skills
Categories
Frontend Development, Testing & QA
First seen
Jun 3, 2026

More from dalestudy/skills

All 9
1jwynia avatarrevealjs-presenterjwynia/agent-skillsGenerate RevealJS HTML presentations with reliable layout, professional typography, and effective visual communication. Use when creating slide decks, pitch pre405skills.sh installs
2dchuk avatarintegrating-tauri-js-frontendsdchuk/claude-code-tauri-skillsGuides Claude through configuring JavaScript frontend frameworks for Tauri v2 desktop applications, including Next.js, Nuxt, Qwik, SvelteKit, and Vite with prop402skills.sh installs
3paperclipai avatardesign-guidepaperclipai/paperclipPaperclip UI design system guide for building consistent, reusable frontend components. Use when creating new UI components, modifying existing ones, adding pag398skills.sh installs
4josiahsiegel avatartailwindcss-fundamentals-v4josiahsiegel/claude-plugin-marketplaceTailwind CSS v4 fundamentals — installation, CSS-first configuration, and 2025-2026 best practices. PROACTIVELY activate for: (1) installing Tailwind v4 (Vite p393skills.sh installs
5zzci avatarpma-webzzci/skillsFrontend implementation guide for PMA-managed React + Vite SPA and internal-tool frontend projects. Covers required quality gates, file-based type-safe routing 391skills.sh installs
6syncfusion avatarsyncfusion-blazor-diagramsyncfusion/blazor-ui-components-skillsBuild and troubleshoot Syncfusion Blazor diagrams using SfDiagramComponent. Trigger for flowcharts, org charts, mind maps, BPMN, UML sequence, swimlanes, symbol387skills.sh installs