react-testing
Test React components with RTL and Jest/Vitest. Use when writing React component tests with React Testing Library, Jest, or Vitest.
от HoangNguyen0403★ 598 звёзд на GitHub
Установить react-testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
React Testing
Priority: P1 (HIGH)
Universal anti-slop rules (naming, identity fixtures, tautologies, skip/focus, mock echoing, bug-first lock, sleeps, shallow assertions, coverage): anti-slop-rules.md. Only web deltas follow.
Core Philosophy
- Test user behavior, not implementation mechanics: verify the app works for users, not how components are built.
- Resistance to refactoring: changing internal state, props, or hooks must not break a test while user-visible behavior holds.
Core Rule Anchors
[WEB-TEST-01]AAA Cadence: Test names followMethod_Scenario_ExpectedBehavior(canonical A11) and every test uses Arrange-Act-Assert.[WEB-TEST-02]Accessible Roles & UserEvent: UseuserEvent.setup()for interactions (await user.click(...)) and query by accessible role (getByRole,findByLabelText). AvoidfireEvent; ban CSS or DOM-hierarchy selectors.[WEB-TEST-03]Ban Component State & Prop Inspection: Never inspect internal state or props. Assert visible user outcomes and DOM changes.[WEB-TEST-04]MSW Network Mocking: Intercept at the HTTP boundary with MSW instead of mocking Apollo hooks (useQuery) or Redux dispatchers; tests must exercise real component data flow.[WEB-TEST-06]Ban Static Artifact Pinning & Twin.test.jsSuites: Never assert staticprint(GQL)query AST text or.loc.source.bodysubstrings (GUARD-TS-STATIC-PINNING); test the hook or query component. Never loopObject.keys(locales/*.json)or asserttypeof en[k] === 'string'; assert rendered text viafindByText/getByRole. Never keep<stem>.test.tsxbeside a legacy<stem>.test.jsx(GUARD-TS-DUAL-EXT); migrate it. Ban pass-through mock echoes (expect(wrapper()).toBe(X)without domain transformations).
Implementation Guidelines
- Standards: RTL with Vitest or Jest; AAA (
[WEB-TEST-01]); reuse existing companion test files. - Selection: Prefer
getByRole,findByLabelText,getByText;data-testidonly as an explicit fallback. - Behavioral Assertions:
userEvent.setup()overfireEvent([WEB-TEST-02]). - Network Boundary: MSW instead of Apollo/Redux mocking (
[WEB-TEST-04]); never call real APIs in unit tests. - TS Hygiene: Apply canonical rule A6 (
GUARD-TS-FLOATING-ASSERT,GUARD-TS-CATCH-ONLY,GUARD-TS-CONDITIONAL-ASSERT,GUARD-TS-SELF-MOCK). BansetTimeoutsleeps > 0ms (GUARD-REACT-02); useawait screen.findBy*orwaitFor.
Anti-Patterns & Banned Smells
- Synthetic events or CSS selectors (
[WEB-TEST-02]): BanfireEventand class/hierarchy queries. - Implementation details (
[WEB-TEST-03]): No internalstate/propsinspection. - Hook / dispatcher mocking (
[WEB-TEST-04]): Use MSW handlers. - Static pinning & twin suites (
[WEB-TEST-06]):GUARD-TS-STATIC-PINNING, locale key loops,GUARD-TS-DUAL-EXT. - Fixed sleeps (
GUARD-REACT-02): BansetTimeoutwaits; preferawait screen.findBy*overwaitFor(() => screen.getBy*). - No large dynamic snapshots: Ban snapshots of dynamic pages, lists, or complex containers.
References
See references/REFERENCE.md for MSW API mocking, Context testing, form testing, and React Router patterns.
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- evals/evals.json
- references/REFERENCE.md
FAQ
Что делает скилл react-testing?
Test React components with RTL and Jest/Vitest. Use when writing React component tests with React Testing Library, Jest, or Vitest.
Как установить скилл react-testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл react-testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…