{"enrichment":{"faq":[{"a":"React Native Testing Library (RNTL) teaches you to write effective tests by rendering components, querying elements with accessibility-first methods, and asserting on behavior. Start by importing render and screen from RNTL, render your component, then use queries like getByRole or getByText to find elements, and apply jest matchers to verify outcomes. Structure tests with clear arrange-act-assert patterns, and always prefer querying by role or semantic properties over test IDs to ensure your tests reflect how real users interact with your app.","q":"How do you write React Native component tests using React Native Testing Library?"},{"a":"React Native Testing Library v14 introduced significant changes to render behavior and async patterns compared to v13. In v14, render is now async by default, requiring you to await it or wrap tests appropriately. The API also refined how waitFor and findBy queries work, with improved handling of act warnings and stricter async/await enforcement. Understanding these version-specific differences is critical: v13 users may need to adjust test structure when upgrading to v14, particularly around render calls and async state updates. Check your package version and adjust your test setup accordingly.","q":"What are the key differences between RNTL v13 and v14 for sync/async render and API behavior?"},{"a":"React Native Testing Library recommends userEvent over fireEvent for most interaction testing because userEvent simulates real user behavior more accurately, including multi-step interactions and proper event sequencing. Use userEvent for typing into TextInput, pressing Pressable components, and other user-initiated actions. Reserve fireEvent only for low-level events that userEvent doesn't support or for testing edge cases. userEvent is async, so always await it in your tests, and be mindful of fake timers when using userEvent\u2014you may need to advance timers or use real timers depending on your test setup.","q":"How should you use userEvent versus fireEvent in React Native Testing Library?"},{"a":"React Native Testing Library encourages getByRole and ARIA-based queries because they reflect how assistive technologies and real users navigate your app, not implementation details. Using getByRole with accessible names ensures your components are actually accessible and forces you to structure markup semantically. Test IDs (getByTestId) couple tests tightly to component internals, making refactoring painful and missing accessibility issues. By querying with getByRole, getByLabelText, and getByText, your tests become more resilient, your components more accessible, and your confidence in real-world usability higher.","q":"Why should you apply accessibility-first querying with getByRole instead of test IDs in RNTL?"},{"a":"React Native Testing Library best practices warn against several anti-patterns: relying on test IDs instead of semantic queries, not awaiting async operations (render, userEvent, waitFor), testing implementation details rather than user behavior, and ignoring act warnings. Avoid querying by component instance or internal state; instead, query by role, text, or label. Don't skip accessibility props just to make tests pass\u2014add proper accessible names and roles to your components. Finally, avoid excessive mocking; test real component interactions when possible. Following these guidelines helps you write maintainable tests that catch real bugs and keep your app accessible.","q":"What are common anti-patterns to avoid when testing React Native components with RNTL?"},{"a":"React Native Testing Library provides waitFor and findBy queries to handle async state updates and delayed renders. findBy queries (like findByRole) are shortcuts that internally use waitFor, so use them when you expect an element to appear after an async operation. waitFor accepts a callback and polls it until the assertion passes or timeout occurs, making it ideal for complex async scenarios. Always await both findBy and waitFor calls. Set appropriate timeouts if your app has slower operations, and remember that waitFor will automatically handle act warnings. Combine these patterns with userEvent for realistic async user interaction testing.","q":"How do you handle waitFor and findBy patterns correctly in React Native Testing Library tests?"}],"shadow_tags":["mobile-testing","jest-matchers","accessibility-queries","async-patterns","user-interactions","version-specific-apis","test-utilities","component-assertions","provider-wrapping","timer-mocking"],"summary_rewrite":"This skill teaches you how to write effective tests for React Native components using React Native Testing Library (RNTL). You'll learn to select elements correctly, structure test cases, and apply assertions that verify component behavior\u2014building confidence in your mobile app's quality and maintainability."},"files":[{"bytes":7315,"path":"skills/react-native-testing/SKILL.md","sha256":"dea54d1d397cbd271a9ee7f6c09e841bb1aa546d9f2a3ee46fd466275061e6e1","url":"https://skillfed.io/files/callstack/react-native-testing-library/react-native-testing/fda2dced/SKILL.md"}],"id":"callstack/react-native-testing-library/react-native-testing","links":{"html":"https://skillfed.io/callstack/react-native-testing-library/react-native-testing","md":"https://skillfed.io/callstack/react-native-testing-library/react-native-testing.md","repo":"https://github.com/callstack/react-native-testing-library"},"meta":{"agents_supported":[],"first_seen":"2026-07-28","forks":281,"language":"TypeScript","last_updated":"2026-07-21","license":"MIT","name":"react-native-testing","publisher":"callstack","stars":3402},"relations":{"similar":[{"id":"callstackincubator/agent-skills/react-native-testing"},{"id":"gohypergiant/agent-skills/accelint-react-testing"},{"id":"itechmeat/llm-code/react-testing-library"},{"id":"DaleStudy/skills/testing"},{"id":"pproenca/dot-skills/react-testing-library"},{"id":"shipshitdev/skills/react-testing-library"},{"id":"manutej/luxor-claude-marketplace/jest-react-testing"},{"id":"hieutrtr/ai1-skills/react-testing-patterns"},{"id":"pluginagentmarketplace/custom-plugin-react-native/react-native-testing"},{"id":"affaan-m/ECC/react-testing"}]},"slug":{"owner":"callstack","repo":"react-native-testing-library","skill":"react-native-testing"},"version":"fda2dced"}
