重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
react-testing-library by pproenca/dot-skills
npx skills add https://github.com/pproenca/dot-skills --skill react-testing-library使用 Testing Library 进行 React 组件测试的综合指南,专为 AI 智能体和 LLM 设计。包含 9 个类别共 43 条规则,按影响优先级排序,以指导测试编写和代码审查。
在以下情况下参考这些指南:
| 优先级 | 类别 | 影响 | 前缀 |
|---|---|---|---|
| 1 | 查询选择 | 关键 | query- |
| 2 | 异步处理 | 关键 | async- |
| 3 | 常见反模式 | 关键 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
anti- |
| 4 | 用户交互 | 高 | user- |
| 5 | 断言 | 高 | assert- |
| 6 | 组件设置 | 中 | setup- |
| 7 | 测试结构 | 中 | struct- |
| 8 | 调试 | 中低 | debug- |
| 9 | 无障碍测试 | 低 | a11y- |
query-prefer-role - 优先使用 getByRole 而非其他查询query-avoid-testid - 避免将 getByTestId 作为主要查询query-use-screen - 使用 screen 进行查询query-label-text-forms - 对表单字段使用 getByLabelTextquery-role-name-option - 将 name 选项与 getByRole 一起使用query-get-vs-query - 使用 getBy 检查存在,queryBy 检查不存在query-within-scope - 使用 within() 来限定查询范围async-findby-over-waitfor - 使用 findBy 替代 waitFor + getByasync-await-findby - 始终 await findBy 查询async-single-assertion-waitfor - 在 waitFor 中使用单一断言async-no-side-effects-waitfor - 避免在 waitFor 中产生副作用async-waitfor-disappear - 使用 waitForElementToBeRemovedanti-unnecessary-act - 避免不必要的 act() 包装anti-manual-cleanup - 移除手动清理调用anti-implementation-details - 避免测试实现细节anti-empty-waitfor - 避免空的 waitFor 回调函数anti-container-queries - 避免使用 container 进行查询anti-redundant-roles - 避免添加冗余的 ARIA 角色user-prefer-userevent - 使用 userEvent 而非 fireEventuser-setup-before-render - 在 render 之前设置 userEventuser-await-interactions - 始终 await userEvent 交互user-keyboard-for-special-keys - 对特殊键使用 keyboard()user-clear-before-type - 在重新输入前使用 clear()assert-jest-dom-matchers - 使用 jest-dom 匹配器assert-visible-over-in-document - 使用 toBeVisible() 检查可见性assert-text-content - 使用 toHaveTextContent() 检查文本assert-have-value - 对输入框使用 toHaveValue()assert-accessible-description - 使用 toHaveAccessibleDescription()setup-wrapper-providers - 使用 wrapper 选项包装 providerssetup-custom-render - 创建包含 providers 的自定义 render 函数setup-mock-modules - 在模块级别模拟模块setup-fake-timers - 使用假计时器配置 userEventsetup-render-hook - 使用 renderHook 测试钩子struct-arrange-act-assert - 遵循 Arrange-Act-Assert 模式struct-one-behavior-per-test - 每个测试只测试一个行为struct-descriptive-names - 使用描述性的测试名称struct-avoid-beforeeach-render - 避免在 beforeEach 中使用 render()debug-screen-debug - 使用 screen.debug() 检查 DOMdebug-logroles - 使用 logRoles 查找可用角色debug-testing-playground - 使用 Testing Playground 辅助查询a11y-role-queries-verify - 角色查询可验证无障碍性a11y-verify-focus - 测试焦点管理a11y-test-aria-states - 测试 ARIA 状态和属性阅读单独的参考文件以获取详细说明和代码示例:
| 文件 | 描述 |
|---|---|
| references/_sections.md | 类别定义和排序 |
| assets/templates/_template.md | 新规则模板 |
| metadata.json | 版本和参考信息 |
每周安装次数
59
仓库
GitHub 星标数
86
首次出现
2026年2月15日
安全审计
安装于
gemini-cli56
codex56
github-copilot56
kimi-cli55
opencode55
amp54
Comprehensive testing guide for React components using Testing Library, designed for AI agents and LLMs. Contains 43 rules across 9 categories, prioritized by impact to guide test writing and code review.
Reference these guidelines when:
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Query Selection | CRITICAL | query- |
| 2 | Async Handling | CRITICAL | async- |
| 3 | Common Anti-Patterns | CRITICAL | anti- |
| 4 | User Interaction | HIGH | user- |
| 5 | Assertions | HIGH | assert- |
| 6 | Component Setup | MEDIUM | setup- |
| 7 | Test Structure | MEDIUM | struct- |
| 8 | Debugging | LOW-MEDIUM | debug- |
| 9 | Accessibility Testing | LOW | a11y- |
query-prefer-role - Prefer getByRole over other queriesquery-avoid-testid - Avoid getByTestId as primary queryquery-use-screen - Use screen for queriesquery-label-text-forms - Use getByLabelText for form fieldsquery-role-name-option - Use name option with getByRoleasync-findby-over-waitfor - Use findBy instead of waitFor + getByasync-await-findby - Always await findBy queriesasync-single-assertion-waitfor - Single assertion in waitForasync-no-side-effects-waitfor - Avoid side effects in waitForasync-waitfor-disappear - Use waitForElementToBeRemovedanti-unnecessary-act - Avoid unnecessary act() wrappinganti-manual-cleanup - Remove manual cleanup callsanti-implementation-details - Avoid testing implementation detailsanti-empty-waitfor - Avoid empty waitFor callbacksanti-container-queries - Avoid using container for queriesuser-prefer-userevent - Use userEvent over fireEventuser-setup-before-render - Setup userEvent before renderuser-await-interactions - Always await userEvent interactionsuser-keyboard-for-special-keys - Use keyboard() for special keysuser-clear-before-type - Use clear() before retypingassert-jest-dom-matchers - Use jest-dom matchersassert-visible-over-in-document - Use toBeVisible() for visibilityassert-text-content - Use toHaveTextContent() for textassert-have-value - Use toHaveValue() for inputsassert-accessible-description - Use toHaveAccessibleDescription()setup-wrapper-providers - Use wrapper option for providerssetup-custom-render - Create custom render with providerssetup-mock-modules - Mock modules at module levelsetup-fake-timers - Configure userEvent with fake timerssetup-render-hook - Use renderHook for testing hooksstruct-arrange-act-assert - Follow Arrange-Act-Assert patternstruct-one-behavior-per-test - Test one behavior per teststruct-descriptive-names - Use descriptive test namesstruct-avoid-beforeeach-render - Avoid render() in beforeEachdebug-screen-debug - Use screen.debug() to inspect DOMdebug-logroles - Use logRoles to find available rolesdebug-testing-playground - Use Testing Playground for queriesa11y-role-queries-verify - Role queries verify accessibilitya11y-verify-focus - Test focus managementa11y-test-aria-states - Test ARIA states and propertiesRead individual reference files for detailed explanations and code examples:
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |
Weekly Installs
59
Repository
GitHub Stars
86
First Seen
Feb 15, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
gemini-cli56
codex56
github-copilot56
kimi-cli55
opencode55
amp54
Vue 3 调试指南:解决响应式、计算属性与监听器常见错误
12,200 周安装
query-get-vs-queryquery-within-scope - Use within() to scope queriesanti-redundant-roles