Repository inventory

citypaul/.dotfiles

Skills indexed from this repository, with install-style signals scoped to the repo.
7 skills3.5K GitHub stars0 weekly installsShellGitHubOwner profile

Overview

This skill provides practical React Testing Library patterns for testing React components, hooks, context, forms, and edge cases like portals, suspense, and error boundaries. It emphasizes testing rendered output and user-visible behavior instead of implementation details. Use these patterns to write reliable, maintainable tests that align with modern RTL conventions.

How this skill works

The skill describes how to use render() and renderHook() to exercise components and hooks, how to wrap tests with providers via the wrapper option, and when to rely on userEvent for user interactions. It highlights RTL auto-wrapping of updates, automatic cleanup, and common anti-patterns to avoid so tests remain focused on what users see. Concrete examples cover controlled inputs, form submission, conditional rendering, loading/error states, portals, and suspense.

When to use it

  • Testing component output and user interactions in React applications
  • Validating custom hooks with renderHook and act where needed
  • Testing components or hooks that rely on Context providers
  • Verifying form behavior, validation, and submission flows
  • Checking UI behavior for loading, error boundaries, portals, and Suspense

Best practices

  • Treat components as functions: assert rendered DOM from props and interactions
  • Use renderHook for hooks and wrapper to provide context providers
  • Prefer userEvent for interactions and avoid unnecessary manual act() or cleanup() calls
  • Avoid testing internal state, instance methods, or using shallow rendering
  • Create per-test factory render functions instead of shared beforeEach renders

Example use cases

  • Render a LoginForm, type credentials with userEvent, click submit, and assert onSubmit called with correct payload
  • Use renderHook to test a useCounter hook with initial props and rerender to assert behavior changes
  • Wrap a Dashboard with AuthProvider in a render helper and assert authenticated UI elements appear
  • Simulate a server error response and assert an error message appears after submit
  • Render a Modal that uses a portal and assert its content is present in the document

FAQ

No. Modern RTL auto-cleans between tests and auto-wraps most updates; manual act() is only needed for direct hook state mutations (renderHook) or rare direct state manipulation.

Should I use shallow rendering or inspect component internals?

No. Prefer full render() and assert on what the user sees. Avoid shallow rendering and testing internal state or methods, which produce brittle tests.

7 skills

More from this maintainer
Other repositories and skills published under the same GitHub owner.
Skills library
Jump back to the full directory or explore grouped topics.
Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational