{"enrichment":{"faq":[{"a":"React Testing Library provides utilities to write tests that simulate real user behavior. Start by rendering your component with `render()`, then query elements using accessible queries like `getByRole()`, `getByLabelText()`, or `getByText()`. Simulate user interactions with `userEvent`, and use `findBy` or `waitFor()` for async operations. This approach prioritizes accessibility and makes tests more maintainable.","q":"How do I test React components with testing library?"},{"a":"React Testing Library offers three query variants: `getBy*` (throws if not found), `queryBy*` (returns null if absent), and `findBy*` (returns a promise for async elements). Query types include `getByRole()` for accessible elements, `getByLabelText()` for form inputs, `getByText()` for content, and `getByPlaceholderText()` for inputs. Role-based queries are preferred as they reflect how users interact with your app.","q":"What are the main query types in React Testing Library?"},{"a":"React Testing Library recommends using `userEvent` instead of `fireEvent` because it simulates real user behavior more accurately. Import `userEvent` from '@testing-library/user-event', then use methods like `userEvent.click()`, `userEvent.type()`, `userEvent.selectOptions()`, and `userEvent.hover()`. UserEvent fires multiple events in sequence, matching how browsers handle actual user input, making tests more reliable.","q":"How should I simulate user interactions instead of fireEvent?"},{"a":"React Testing Library provides `findBy*` queries and `waitFor()` for async testing. Use `findBy*` when expecting elements to appear after async operations\u2014it returns a promise that resolves when found. For more complex async scenarios, wrap assertions in `waitFor()` to poll until conditions are met. Avoid `act()` warnings by letting Testing Library handle updates automatically through user interactions and async queries.","q":"What patterns should I use for testing async behavior?"},{"a":"React Testing Library's `renderHook()` utility lets you test hooks in isolation. Import it from '@testing-library/react', call `renderHook(() => useMyHook())`, and access the hook's return value via `result.current`. For async hooks, use `waitFor()` to wait for state updates. Pass props through the `initialProps` option and update them with `rerender()` to test how hooks respond to prop changes.","q":"How do I test React hooks with renderHook?"},{"a":"React Testing Library prioritizes accessible queries to encourage writing inclusive components. Use `getByRole()` to query semantic elements, `getByLabelText()` for form fields, and avoid implementation details like test IDs when possible. This approach ensures your tests verify that components work for all users, including those using assistive technologies. Custom render functions with providers and jest-dom matchers enhance accessibility testing.","q":"What accessibility-first testing patterns does React Testing Library promote?"}],"shadow_tags":["user-centric-testing","accessibility-first","dom-queries","async-utilities","event-simulation","jest-integration","component-unit-tests","role-based-selection","anti-pattern-guide"],"summary_rewrite":"React Testing Library guides you through writing tests that mirror real user behavior rather than internal implementation. It emphasizes querying by role, label, and text\u2014prioritizing accessibility\u2014and provides utilities for simulating user interactions, handling async operations, and debugging. Master query types, user events, and common patterns like custom renders and hook testing."},"files":[{"bytes":9880,"path":"skills/react-testing-library/SKILL.md","sha256":"8049f7c21c305be83116e0b86a16966a92169d6dfd5afe029dd9167e0fdedb7a","url":"https://skillfed.io/files/itechmeat/llm-code/react-testing-library/4f64b566/SKILL.md"}],"id":"itechmeat/llm-code/react-testing-library","links":{"html":"https://skillfed.io/itechmeat/llm-code/react-testing-library","md":"https://skillfed.io/itechmeat/llm-code/react-testing-library.md","repo":"https://github.com/itechmeat/llm-code"},"meta":{"agents_supported":[],"first_seen":"2026-07-28","forks":1,"language":"Go","last_updated":"2026-07-18","license":"MIT","name":"react-testing-library","publisher":"itechmeat","stars":21},"relations":{"similar":[{"id":"DaleStudy/skills/testing"},{"id":"manutej/luxor-claude-marketplace/jest-react-testing"},{"id":"hieutrtr/ai1-skills/react-testing-patterns"},{"id":"gohypergiant/agent-skills/accelint-react-testing"},{"id":"callstackincubator/agent-skills/react-native-testing"},{"id":"callstack/react-native-testing-library/react-native-testing"},{"id":"majesticlabs-dev/majestic-marketplace/react-testing"},{"id":"affaan-m/ECC/react-testing"},{"id":"jmsktm/claude-settings/testing-qa"},{"id":"prowler-cloud/prowler/vitest"}]},"slug":{"owner":"itechmeat","repo":"llm-code","skill":"react-testing-library"},"version":"4f64b566"}
