Тестирование React-компонентов — Testing Library + Vitest/Jest, поведенческие проверки от лица пользователя, MSW для мокинга сети. Use при написании или ревью тестов фронтенда.
Scanned 9/11/2026
Install to Claude Code
npx -y skills add Vitammiin/agent-vorcl-flow --skill react-testing --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of React Testing?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/vitammiin-react-testing)More formats (shields.io, HTML) on the badges page.
---
name: react-testing
description: Тестирование React-компонентов — Testing Library + Vitest/Jest, поведенческие проверки от лица пользователя, MSW для мокинга сети. Use при написании или ревью тестов фронтенда.
---
# Навык: React testing
Поведенческие тесты компонентов на **Testing Library** + **Vitest** (или Jest).
## Принцип
- Тестируй поведение, а не реализацию.
- Поиск по ролям/тексту: `getByRole`, `getByLabelText`, `findByText`; `data-testid` — крайняя мера.
- Взаимодействие — `@testing-library/user-event`.
## Структура (AAA)
- Arrange (рендер + провайдеры) → Act (действие) → Assert (видимый результат).
- Провайдеры (QueryClientProvider, стор, тема) — через `renderWithProviders`.
## Сеть и данные
- Мокай границу сети через **MSW**, не внутренние модули.
- Свежий `QueryClient` на тест, `retry: false`.
## Асинхронность
- `await findBy*` / `await waitFor(...)`; не по таймингу.
- Проверяй loading/empty/error, не только happy path.
## Пример
```tsx
test('показывает заказы', async () => {
renderWithProviders(<OrdersList />);
expect(await screen.findByText('Заказ #1')).toBeInTheDocument();
});
```
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!