{"id":13406714,"url":"https://github.com/callstack/react-native-testing-library","last_synced_at":"2026-01-04T17:13:42.883Z","repository":{"id":37752176,"uuid":"151103020","full_name":"callstack/react-native-testing-library","owner":"callstack","description":"🦉 Simple and complete React Native testing utilities that encourage good testing practices.","archived":false,"fork":false,"pushed_at":"2025-05-05T14:26:13.000Z","size":27646,"stargazers_count":3191,"open_issues_count":8,"forks_count":273,"subscribers_count":29,"default_branch":"main","last_synced_at":"2025-05-14T08:04:21.416Z","etag":null,"topics":["hacktoberfest","jest","react","react-native","testing"],"latest_commit_sha":null,"homepage":"https://callstack.github.io/react-native-testing-library/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/callstack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-10-01T14:32:13.000Z","updated_at":"2025-05-14T07:32:08.000Z","dependencies_parsed_at":"2024-01-05T13:39:31.304Z","dependency_job_id":"aad799fa-ac6e-47bb-af92-b037d415b400","html_url":"https://github.com/callstack/react-native-testing-library","commit_stats":{"total_commits":1028,"total_committers":132,"mean_commits":7.787878787878788,"dds":0.7538910505836576,"last_synced_commit":"0632000f1e8875b3ae53f2051c1e577fc74f5c81"},"previous_names":[],"tags_count":113,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callstack%2Freact-native-testing-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callstack%2Freact-native-testing-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callstack%2Freact-native-testing-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callstack%2Freact-native-testing-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/callstack","download_url":"https://codeload.github.com/callstack/react-native-testing-library/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101588,"owners_count":22014907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","jest","react","react-native","testing"],"created_at":"2024-07-30T19:02:37.361Z","updated_at":"2026-01-04T17:13:42.871Z","avatar_url":"https://github.com/callstack.png","language":"TypeScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://www.callstack.com/open-source?utm_campaign=generic\u0026utm_source=github\u0026utm_medium=referral\u0026utm_content=react-native-testing-library\" align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/user-attachments/assets/4d452312-4ffd-4439-855f-a9b12ad7d6c2\" alt=\"React Native Testing Library\" /\u003e\n  \u003c/a\u003e\n  \u003cp align=\"center\"\u003eDeveloper-friendly and complete React Native testing utilities that encourage good testing practices.\u003c/p\u003e\n\u003c/div\u003e\n\n[![Version][version-badge]][package]\n[![Build Status][build-badge]][build]\n[![Code Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![MIT License][license-badge]][license]\n[![Sponsored by Callstack][callstack-badge]][callstack]\n\n## The problem\n\nYou want to write maintainable tests for your React Native components. As a part of this goal, you want your tests to avoid including implementation details of your components and rather focus on making your tests give you the confidence for which they are intended. As part of this, you want your tests to be maintainable in the long run so refactors of your components (changes to implementation but not functionality) don't break your tests and slow you and your team down.\n\n## This solution\n\nThe React Native Testing Library (RNTL) is a comprehensive solution for testing React Native components. It provides React Native runtime simulation on top of `react-test-renderer`, in a way that encourages better testing practices. Its primary guiding principle is:\n\n\u003e The more your tests resemble the way your software is used, the more confidence they can give you.\n\nThis project is inspired by [React Testing Library](https://github.com/testing-library/react-testing-library). Tested to work with Jest, but it should work with other test runners as well.\n\n## Installation\n\nOpen a Terminal in your project's folder and run:\n\n```sh\n# Yarn install:\nyarn add --dev @testing-library/react-native\n\n# NPM install\nnpm install --save-dev @testing-library/react-native\n```\n\nThis library has a `peerDependencies` listing for `react-test-renderer`. Make sure that your `react-test-renderer` version matches exactly the `react` version, avoid using `^` in version number.\n\n### Additional Jest matchers\n\nYou can use the built-in Jest matchers automatically by having any import from `@testing-library/react-native` in your test.\n\n## Example\n\n```jsx\nimport { render, screen, userEvent } from '@testing-library/react-native';\nimport { QuestionsBoard } from '../QuestionsBoard';\n\n// It is recommended to use userEvent with fake timers\n// Some events involve duration so your tests may take a long time to run.\njest.useFakeTimers();\n\ntest('form submits two answers', async () =\u003e {\n  const questions = ['q1', 'q2'];\n  const onSubmit = jest.fn();\n\n  const user = userEvent.setup();\n  render(\u003cQuestionsBoard questions={questions} onSubmit={onSubmit} /\u003e);\n\n  const answerInputs = screen.getAllByLabelText('answer input');\n\n  // simulates the user focusing on TextInput and typing text one char at a time\n  await user.type(answerInputs[0], 'a1');\n  await user.type(answerInputs[1], 'a2');\n\n  // simulates the user pressing on any pressable element\n  await user.press(screen.getByRole('button', { name: 'Submit' }));\n\n  expect(onSubmit).toHaveBeenCalledWith({\n    1: { q: 'q1', a: 'a1' },\n    2: { q: 'q2', a: 'a2' },\n  });\n});\n```\n\nYou can find the source of `QuestionsBoard` component and this example [here](https://github.com/callstack/react-native-testing-library/blob/main/src/__tests__/questionsBoard.test.tsx).\n\n## API / Usage\n\nReact Native Testing Library consists of following APIs:\n\n- [`render` function](https://callstack.github.io/react-native-testing-library/docs/api/render) - render your UI components for testing purposes\n- [`screen` object](https://callstack.github.io/react-native-testing-library/docs/api/screen) - access rendered UI:\n  - [Queries](https://callstack.github.io/react-native-testing-library/docs/api/queries) - find rendered components by various predicates: role, text, test ids, etc\n  - Lifecycle methods: [`rerender`](https://callstack.github.io/react-native-testing-library/docs/api/screen#rerender), [`unmount`](https://callstack.github.io/react-native-testing-library/docs/api/screen#unmount)\n  - Helpers: [`debug`](https://callstack.github.io/react-native-testing-library/docs/api/screen#debug), [`toJSON`](https://callstack.github.io/react-native-testing-library/docs/api/screen#tojson), [`root`](https://callstack.github.io/react-native-testing-library/docs/api/screen#root)\n- [Jest matchers](https://callstack.github.io/react-native-testing-library/docs/api/jest-matchers) - validate assumptions about your UI\n- [User Event](https://callstack.github.io/react-native-testing-library/docs/api/events/user-event) - simulate common user interactions like [`press`](https://callstack.github.io/react-native-testing-library/docs/api/events/user-event#press) or [`type`](https://callstack.github.io/react-native-testing-library/docs/user-event#type) in a realistic way\n- [Fire Event](https://callstack.github.io/react-native-testing-library/docs/api/events/fire-event) - simulate any component event in a simplified way\n- [`renderHook` function](https://callstack.github.io/react-native-testing-library/docs/api/misc/render-hook) - render hooks for testing purposes\n- Miscellaneous APIs:\n  - [Async utils](https://callstack.github.io/react-native-testing-library/docs/api/misc/async): `findBy*` queries, `waitFor`, `waitForElementToBeRemoved`\n  - [Configuration](https://callstack.github.io/react-native-testing-library/docs/api/misc/config): `configure`, `resetToDefaults`\n  - [Accessibility](https://callstack.github.io/react-native-testing-library/docs/api/misc/accessibility): `isHiddenFromAccessibility`\n  - [Other](https://callstack.github.io/react-native-testing-library/docs/api/misc/other): `within`, `act`, `cleanup`\n\n## Migration Guides\n\n- [Migration to 13.0](https://callstack.github.io/react-native-testing-library/docs/migration/v13)\n- [Migration to built-in Jest Matchers](https://callstack.github.io/react-native-testing-library/docs/migration/jest-matchers)\n\n## Troubleshooting\n\n- [Troubleshooting guide](https://callstack.github.io/react-native-testing-library/docs/guides/troubleshooting)\n\n## Community Resources\n\nCheck out our list of [Community Resources about RNTL](https://callstack.github.io/react-native-testing-library/docs/guides/community-resources).\n\n## Made with ❤️ at Callstack\n\nReact Native Testing Library is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. [Callstack](https://callstack.com) is a group of React and React Native geeks, contact us at [hello@callstack.com](mailto:hello@callstack.com) if you need any help with these or just want to say hi!\n\nLike the project? ⚛️ [Join the team](https://callstack.com/careers/?utm_campaign=Senior_RN\u0026utm_source=github\u0026utm_medium=readme) who does amazing stuff for clients and drives React Native Open Source! 🔥\n\n---\n\nSupported and used by [Rally Health](https://www.rallyhealth.com/careers).\n\n\u003c!-- badges --\u003e\n\n[version-badge]: https://img.shields.io/npm/v/@testing-library/react-native.svg?style=flat-square\n[package]: https://www.npmjs.com/package/@testing-library/react-native\n[build-badge]: https://github.com/callstack/react-native-testing-library/actions/workflows/ci.yml/badge.svg\n[build]: https://github.com/callstack/react-native-testing-library/actions/workflows/ci.yml\n[coverage-badge]: https://img.shields.io/codecov/c/github/callstack/react-native-testing-library.svg\n[coverage]: https://codecov.io/github/callstack/react-native-testing-library\n[downloads-badge]: https://img.shields.io/npm/dm/@testing-library/react-native.svg?style=flat-square\n[downloads]: http://www.npmtrends.com/@testing-library/react-native\n[license-badge]: https://img.shields.io/npm/l/@testing-library/react-native.svg\n[license]: https://opensource.org/licenses/MIT\n[callstack-badge]: https://callstack.com/images/callstack-badge.svg\n[callstack]: https://callstack.com/open-source/?utm_source=github.com\u0026utm_medium=referral\u0026utm_campaign=react-native-testing-library\u0026utm_term=readme\n","funding_links":[],"categories":["TypeScript","Unit Testing","JavaScript","Testing"],"sub_categories":["Assertion","Graphics \u0026 Drawing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcallstack%2Freact-native-testing-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcallstack%2Freact-native-testing-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcallstack%2Freact-native-testing-library/lists"}