Skip to content
Back to skills

Component Testing

ASecurity

Comprehensive testing patterns for React components with MSW, React Query, and Vitest. Use when writing tests, setting up mocks, testing API interactions, or ensuring 80% coverage. Keywords - testing, MSW, React Query, Vitest, mocks, coverage, API testing.

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 27, 2026
testingtypescriptreacttestinggitapidocumentation

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 27, 2026

npx -y skills add David-Li0406/meta-skill-evloving --skill component-testing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Component Testing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Component Testing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-component-testing/badge)](https://www.skillsdirectory.com/skills/david-li0406-component-testing)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: component-testing
description: Comprehensive testing patterns for React components with MSW, React Query, and Vitest. Use when writing tests, setting up mocks, testing API interactions, or ensuring 80% coverage. Keywords - testing, MSW, React Query, Vitest, mocks, coverage, API testing.
license: MIT
metadata:
  version: "2.0.0"
  author: jpmorgan-payments
  lastUpdated: "2025-12-24"
  priority: critical
---

# Component Testing Patterns

Comprehensive testing patterns for React components with MSW, React Query, and Vitest. All components require comprehensive tests with minimum 80% coverage.

## When to Apply

Reference these patterns when:
- Writing new component tests
- Setting up MSW mocks for API interactions
- Testing React Query data fetching
- Ensuring test coverage requirements
- Testing user interactions and form validation
- Testing error states and loading states

## Quick Reference

### Test File Structure

- **File naming:** `ComponentName.test.tsx` next to `ComponentName.tsx`
- **Minimum coverage:** 80% line coverage
- **Colocation:** Tests must be next to implementation files

### Essential Setup

```typescript
import { render, screen, waitFor } from "@testing-library/react";
import { http, HttpResponse } from "msw";
import { server } from "@/msw/server";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
```

### Test Coverage Requirements

- ✅ Minimum 80% line coverage
- ✅ Cover all user interaction paths
- ✅ Test all API integration points
- ✅ Verify error handling and edge cases
- ✅ Test accessibility features

## How to Use

For detailed instructions, examples, and patterns:

- **Full guide**: `AGENTS.md` - Complete testing documentation
- **Individual rules**: See `rules/` directory for specific testing patterns

## References

- See `embedded-components/ARCHITECTURE.md` for architecture patterns
- See `AGENTS.md` for complete testing documentation
- See `.github/skills/code-quality-workflow/` for testing workflows

Files in this skill

  • AGENTS.md7.7 KB
  • SKILL.md2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in testing →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.