{"id":13725514,"url":"https://github.com/testing-library/jest-native","last_synced_at":"2025-10-08T02:11:11.490Z","repository":{"id":34479504,"uuid":"179419190","full_name":"testing-library/jest-native","owner":"testing-library","description":"🦅 Custom jest matchers to test the state of React Native","archived":false,"fork":false,"pushed_at":"2025-03-05T10:25:56.000Z","size":241,"stargazers_count":438,"open_issues_count":7,"forks_count":44,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-09-24T20:53:58.904Z","etag":null,"topics":["custom-jest-matchers","hacktoberfest","javascript","jest","react-native","reactjs","testing"],"latest_commit_sha":null,"homepage":"https://www.npm.im/@testing-library/jest-native","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/testing-library.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"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":"2019-04-04T04:05:51.000Z","updated_at":"2025-07-25T01:31:23.000Z","dependencies_parsed_at":"2025-04-14T14:03:17.927Z","dependency_job_id":null,"html_url":"https://github.com/testing-library/jest-native","commit_stats":{"total_commits":151,"total_committers":39,"mean_commits":3.871794871794872,"dds":0.8278145695364238,"last_synced_commit":"fd0d7452947dc6272f5d36fdf20ff2ed41af47f9"},"previous_names":["bcarroll22/jest-native"],"tags_count":49,"template":false,"template_full_name":null,"purl":"pkg:github/testing-library/jest-native","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testing-library%2Fjest-native","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testing-library%2Fjest-native/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testing-library%2Fjest-native/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testing-library%2Fjest-native/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/testing-library","download_url":"https://codeload.github.com/testing-library/jest-native/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testing-library%2Fjest-native/sbom","scorecard":{"id":875150,"data":{"date":"2025-08-11","repo":{"name":"github.com/testing-library/jest-native","commit":"47fc1ab54afdf625f74e47db7e4dda42ec7fb62a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.4,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":6,"reason":"Found 14/23 approved changesets -- score normalized to 6","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/validate.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/jest-native/validate.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/validate.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/jest-native/validate.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/validate.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/jest-native/validate.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/validate.yml:56: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/jest-native/validate.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/validate.yml:59: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/jest-native/validate.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/validate.yml:64: update your workflow using https://app.stepsecurity.io/secureworkflow/testing-library/jest-native/validate.yml/main?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/validate.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 26 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-24T05:41:45.876Z","repository_id":34479504,"created_at":"2025-08-24T05:41:45.876Z","updated_at":"2025-08-24T05:41:45.876Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278877092,"owners_count":26061381,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["custom-jest-matchers","hacktoberfest","javascript","jest","react-native","reactjs","testing"],"created_at":"2024-08-03T01:02:25.685Z","updated_at":"2025-10-08T02:11:11.444Z","avatar_url":"https://github.com/testing-library.png","language":"TypeScript","readme":"\u003e [!CAUTION]\n\u003e **This package is deprecated and is no longer actively maintained.**\n\u003e \n\u003e We encourage you to migrate to React Native Testing Library, v12.4 or later, which includes modern [built-in Jest matchers](https://callstack.github.io/react-native-testing-library/docs/api/jest-matchers) based on the matchers for this repository.\n\u003e\n\u003e The migration process should be relatively straightforward, we have a [migration guide](https://callstack.github.io/react-native-testing-library/docs/migration/jest-matchers) available.\n\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003ejest-native\u003c/h1\u003e\n\n  \u003ca href=\"https://www.joypixels.com/emoji/1f985\"\u003e\n    \u003cimg\n      height=\"80\"\n      width=\"80\"\n      alt=\"eagle\"\n      src=\"https://raw.githubusercontent.com/testing-library/jest-native/HEAD/other/eagle.png\"\n    /\u003e\n  \u003c/a\u003e\n\n  \u003cp\u003eCustom jest matchers to test the state of React Native.\u003c/p\u003e\n\u003c/div\u003e\n\n\u003chr /\u003e\n\n[![version](https://img.shields.io/npm/v/@testing-library/jest-native.svg?style=flat-square)](https://www.npmjs.com/package/@testing-library/jest-native)\n[![Code Coverage](https://img.shields.io/codecov/c/github/testing-library/jest-native.svg?style=flat-square)](https://codecov.io/github/testing-library/jest-native)\n![Build](https://github.com/testing-library/jest-native/actions/workflows/validate.yml/badge.svg)\n[![downloads](https://img.shields.io/npm/dm/@testing-library/jest-native.svg?style=flat-square)](http://www.npmtrends.com/@testing-library/jest-native)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n[![Discord](https://img.shields.io/discord/723559267868737556.svg?color=7389D8\u0026labelColor=6A7EC2\u0026logo=discord\u0026logoColor=ffffff\u0026style=flat-square)](https://discord.gg/testing-library)\n[![Star on GitHub](https://img.shields.io/github/stars/testing-library/jest-native.svg?style=social)](https://github.com/testing-library/jest-native/stargazers)\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n## Table of Contents\n\n- [The problem](#the-problem)\n- [This solution](#this-solution)\n- [Compatibility](#compatibility)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Extending Jest matchers](#extending-jest-matchers)\n  - [TypeScript support](#typescript-support)\n- [Matchers](#matchers)\n  - [`toBeDisabled`](#tobedisabled)\n  - [`toBeEnabled`](#tobeenabled)\n  - [`toBeEmptyElement`](#tobeemptyelement)\n  - [`toContainElement`](#tocontainelement)\n  - [`toBeOnTheScreen`](#tobeonthescreen)\n  - [`toHaveProp`](#tohaveprop)\n  - [`toHaveTextContent`](#tohavetextcontent)\n  - [`toHaveStyle`](#tohavestyle)\n  - [`toBeVisible`](#tobevisible)\n  - [`toHaveAccessibilityState`](#tohaveaccessibilitystate)\n  - [`toHaveAccessibilityValue`](#tohaveaccessibilityvalue)\n- [Inspiration](#inspiration)\n- [Other solutions](#other-solutions)\n- [Contributors](#contributors)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## The problem\n\nYou want to use [jest](https://facebook.github.io/jest/) to write tests that assert various things\nabout the state of a React Native app. As part of that goal, you want to avoid all the repetitive\npatterns that arise in doing so like checking for a native element's props, its text content, its\nstyles, and more.\n\n## This solution\n\nThe `jest-native` library provides a set of custom jest matchers that you can use to extend jest.\nThese will make your tests more declarative, clear to read and to maintain.\n\n## Compatibility\n\nThese matchers should, for the most part, be agnostic enough to work with any React Native testing\nutilities, but they are primarily intended to be used with\n[React Native Testing Library](https://github.com/callstack/react-native-testing-library). Any\nissues raised with existing matchers or any newly proposed matchers must be viewed through\ncompatibility with that library and its guiding principles first.\n\n## Installation\n\nThis module should be installed as one of your project's `devDependencies`:\n\n#### Using `yarn`\n\n```sh\nyarn add --dev @testing-library/jest-native\n```\n\n#### Using `npm`\n\n```sh\nnpm install --save-dev @testing-library/jest-native\n```\n\nYou will need `react-test-renderer`, `react`, and `react-native` installed in order to use this\npackage.\n\n## Usage\n\n### Extending Jest matchers\n\nImport `@testing-library/jest-native/extend-expect` once (for instance in your\n[tests setup file](https://jestjs.io/docs/configuration#setupfilesafterenv-array)) and you're good\nto go:\n\n```javascript\nimport '@testing-library/jest-native/extend-expect';\n```\n\nAlternatively, you can selectively import only the matchers you intend to use, and extend jest's\n`expect` yourself:\n\n```javascript\nimport { toBeEmptyElement, toHaveTextContent } from '@testing-library/jest-native';\n\nexpect.extend({ toBeEmptyElement, toHaveTextContent });\n```\n\n### TypeScript support\n\nIn order to setup proper TypeScript type checking use either one of the following approches.\n\n#### 1. Use TypeScript Jest setup file.\n\nUse `jest-setup.ts` file (instead of `jest-setup.js` file) which is added to Jest config's `setupFilesAfterEnv` option.\n\nThe Jest setup file should contain following line:\n\n```typescript\nimport '@testing-library/jest-native/extend-expect';\n```\n\nThis should enable TypeScript checkign for both `tsc` and VS Code intellisense.\n\n#### 2. Use `declarations.d.ts` file\n\nAlternatively, create `declarations.d.ts` file at the root level of your project, if it does not exist already.\n\nAdd following line at the top of your `declarations.d.ts`:\n\n```\n/// \u003creference types=\"@testing-library/jest-native\" /\u003e\n```\n\nThis should enable TypeScript checkign for both `tsc` and VS Code intellisense.\n\n## Matchers\n\n`jest-native` has only been tested to work with\n[React Native Testing Library](https://github.com/callstack/react-native-testing-library). Keep in\nmind that these queries are intended only to work with elements corresponding to\n[host components](https://reactnative.dev/architecture/glossary#react-host-components-or-host-components).\n\n### `toBeDisabled`\n\n```javascript\ntoBeDisabled();\n```\n\nCheck whether or not an element is disabled from a user perspective.\n\nThis matcher will check if the element or its parent has any of the following props :\n\n- `disabled`\n- `accessibilityState={{ disabled: true }}`\n- `editable={false}` (for `TextInput` only)\n\n#### Examples\n\n```javascript\nconst { getByTestId } = render(\n  \u003cView\u003e\n    \u003cButton disabled testID=\"button\" title=\"submit\" onPress={(e) =\u003e e} /\u003e\n    \u003cTextInput accessibilityState={{ disabled: true }} testID=\"input\" value=\"text\" /\u003e\n  \u003c/View\u003e,\n);\n\nexpect(getByTestId('button')).toBeDisabled();\nexpect(getByTestId('input')).toBeDisabled();\n```\n\n### `toBeEnabled`\n\n```javascript\ntoBeEnabled();\n```\n\nCheck whether or not an element is enabled from a user perspective.\n\nWorks similarly to `expect().not.toBeDisabled()`.\n\n#### Examples\n\n```javascript\nconst { getByTestId } = render(\n  \u003cView\u003e\n    \u003cButton testID=\"button\" title=\"submit\" onPress={(e) =\u003e e} /\u003e\n    \u003cTextInput testID=\"input\" value=\"text\" /\u003e\n  \u003c/View\u003e,\n);\n\nexpect(getByTestId('button')).toBeEnabled();\nexpect(getByTestId('input')).toBeEnabled();\n```\n\n### `toBeEmptyElement`\n\n```javascript\ntoBeEmptyElement();\n```\n\nCheck that the given element has no content.\n\n#### Examples\n\n```javascript\nconst { getByTestId } = render(\u003cView testID=\"empty\" /\u003e);\n\nexpect(getByTestId('empty')).toBeEmptyElement();\n```\n\n\u003e **Note**\u003cbr/\u003e This matcher has been previously named `toBeEmpty()`, but we changed that name in\n\u003e order to avoid conflict with Jest Extendend matcher with the\n\u003e [same name](https://github.com/jest-community/jest-extended#tobeempty).\n\n### `toContainElement`\n\n```typescript\ntoContainElement(element: ReactTestInstance | null);\n```\n\nCheck if an element contains another element as a descendant. Again, will only work for native\nelements.\n\n#### Examples\n\n```javascript\nconst { queryByTestId } = render(\n  \u003cView testID=\"grandparent\"\u003e\n    \u003cView testID=\"parent\"\u003e\n      \u003cView testID=\"child\" /\u003e\n    \u003c/View\u003e\n    \u003cText testID=\"text-element\" /\u003e\n  \u003c/View\u003e,\n);\n\nconst grandparent = queryByTestId('grandparent');\nconst parent = queryByTestId('parent');\nconst child = queryByTestId('child');\nconst textElement = queryByTestId('text-element');\n\nexpect(grandparent).toContainElement(parent);\nexpect(grandparent).toContainElement(child);\nexpect(grandparent).toContainElement(textElement);\nexpect(parent).toContainElement(child);\nexpect(parent).not.toContainElement(grandparent);\n```\n\n### `toBeOnTheScreen`\n\n```ts\ntoBeOnTheScreen();\n```\n\nCheck that the element is present in the element tree.\n\nYou can check that an already captured element has not been removed from the element tree.\n\n\u003e **Note**\u003cbr/\u003e This matcher requires React Native Testing Library v10.1 or later, as it includes\n\u003e the `screen` object.\n\u003e\n\u003e **Note**\u003cbr/\u003e If you're using React Native Testing Library v12 or later, you need to install Jest\n\u003e Native v5.4.2 or later.\n\n#### Examples\n\n```tsx\nrender(\n  \u003cView\u003e\n    \u003cView testID=\"child\" /\u003e\n  \u003c/View\u003e,\n);\n\nconst child = screen.getByTestId('child');\nexpect(child).toBeOnTheScreen();\n\nscreen.update(\u003cView /\u003e);\nexpect(child).not.toBeOnTheScreen();\n```\n\n### `toHaveProp`\n\n```typescript\ntoHaveProp(prop: string, value?: any);\n```\n\nCheck that the element has a given prop.\n\nYou can optionally check that the attribute has a specific expected value.\n\n#### Examples\n\n```javascript\nconst { queryByTestId } = render(\n  \u003cView\u003e\n    \u003cText allowFontScaling={false} testID=\"text\"\u003e\n      text\n    \u003c/Text\u003e\n    \u003cButton disabled testID=\"button\" title=\"ok\" /\u003e\n  \u003c/View\u003e,\n);\n\nexpect(queryByTestId('button')).toHaveProp('accessible');\nexpect(queryByTestId('button')).not.toHaveProp('disabled');\nexpect(queryByTestId('button')).not.toHaveProp('title', 'ok');\n```\n\n### `toHaveTextContent`\n\n```typescript\ntoHaveTextContent(text: string | RegExp, options?: { normalizeWhitespace: boolean });\n```\n\nCheck if an element or its children have the supplied text.\n\nThis will perform a partial, case-sensitive match when a string match is provided. To perform a\ncase-insensitive match, you can use a `RegExp` with the `/i` modifier.\n\nTo enforce matching the complete text content, pass a `RegExp`.\n\n#### Examples\n\n```javascript\nconst { queryByTestId } = render(\u003cText testID=\"count-value\"\u003e2\u003c/Text\u003e);\n\nexpect(queryByTestId('count-value')).toHaveTextContent('2');\nexpect(queryByTestId('count-value')).toHaveTextContent(2);\nexpect(queryByTestId('count-value')).toHaveTextContent(/2/);\nexpect(queryByTestId('count-value')).not.toHaveTextContent('21');\n```\n\n### `toHaveStyle`\n\n```typescript\ntoHaveStyle(style: object[] | object);\n```\n\nCheck if an element has the supplied styles.\n\nYou can pass either an object of React Native style properties, or an array of objects with style\nproperties. You cannot pass properties from a React Native stylesheet.\n\n#### Examples\n\n```javascript\nconst styles = StyleSheet.create({ text: { fontSize: 16 } });\n\nconst { queryByText } = render(\n  \u003cText\n    style={[\n      { color: 'black', fontWeight: '600', transform: [{ scale: 2 }, { rotate: '45deg' }] },\n      styles.text,\n    ]}\n  \u003e\n    Hello World\n  \u003c/Text\u003e,\n);\n\nexpect(getByText('Hello World')).toHaveStyle({ color: 'black' });\nexpect(getByText('Hello World')).toHaveStyle({ fontWeight: '600' });\nexpect(getByText('Hello World')).toHaveStyle({ fontSize: 16 });\nexpect(getByText('Hello World')).toHaveStyle([{ fontWeight: '600' }, { color: 'black' }]);\nexpect(getByText('Hello World')).toHaveStyle({ color: 'black', fontWeight: '600', fontSize: 16 });\nexpect(getByText('Hello World')).toHaveStyle({ transform: [{ scale: 2 }, { rotate: '45deg' }] });\nexpect(getByText('Hello World')).not.toHaveStyle({ color: 'white' });\nexpect(getByText('Hello World')).not.toHaveStyle({ transform: [{ scale: 2 }] });\nexpect(getByText('Hello World')).not.toHaveStyle({\n  transform: [{ rotate: '45deg' }, { scale: 2 }],\n});\n```\n\n### `toBeVisible`\n\n```typescript\ntoBeVisible();\n```\n\nCheck that the given element is visible to the user.\n\nAn element is visible if **all** the following conditions are met:\n\n- it does not have its style property `display` set to `none`.\n- it does not have its style property `opacity` set to `0`.\n- it is not a `Modal` component or it does not have the prop `visible` set to `false`.\n- it is not hidden from accessibility as checked by\n  [`isHiddenFromAccessibility`](https://callstack.github.io/react-native-testing-library/docs/api/#ishiddenfromaccessibility)\n  function from React Native Testing Library\n- its ancestor elements are also visible.\n\n#### Examples\n\n```javascript\nconst { getByTestId } = render(\u003cView testID=\"empty-view\" /\u003e);\n\nexpect(getByTestId('empty-view')).toBeVisible();\n```\n\n```javascript\nconst { getByTestId } = render(\u003cView testID=\"view-with-opacity\" style={{ opacity: 0.2 }} /\u003e);\n\nexpect(getByTestId('view-with-opacity')).toBeVisible();\n```\n\n```javascript\nconst { getByTestId } = render(\u003cModal testID=\"empty-modal\" /\u003e);\n\nexpect(getByTestId('empty-modal')).toBeVisible();\n```\n\n```javascript\nconst { getByTestId } = render(\n  \u003cModal\u003e\n    \u003cView\u003e\n      \u003cView testID=\"view-within-modal\" /\u003e\n    \u003c/View\u003e\n  \u003c/Modal\u003e,\n);\n\nexpect(getByTestId('view-within-modal')).toBeVisible();\n```\n\n```javascript\nconst { getByTestId } = render(\u003cView testID=\"invisible-view\" style={{ opacity: 0 }} /\u003e);\n\nexpect(getByTestId('invisible-view')).not.toBeVisible();\n```\n\n```javascript\nconst { getByTestId } = render(\u003cView testID=\"display-none-view\" style={{ display: 'none' }} /\u003e);\n\nexpect(getByTestId('display-none-view')).not.toBeVisible();\n```\n\n```javascript\nconst { getByTestId } = render(\n  \u003cView style={{ opacity: 0 }}\u003e\n    \u003cView\u003e\n      \u003cView testID=\"view-within-invisible-view\" /\u003e\n    \u003c/View\u003e\n  \u003c/View\u003e,\n);\n\nexpect(getByTestId('view-within-invisible-view')).not.toBeVisible();\n```\n\n```javascript\nconst { getByTestId } = render(\n  \u003cView style={{ display: 'none' }}\u003e\n    \u003cView\u003e\n      \u003cView testID=\"view-within-display-none-view\" /\u003e\n    \u003c/View\u003e\n  \u003c/View\u003e,\n);\n\nexpect(getByTestId('view-within-display-none-view')).not.toBeVisible();\n```\n\n```javascript\nconst { getByTestId } = render(\n  \u003cModal visible={false}\u003e\n    \u003cView\u003e\n      \u003cView testID=\"view-within-not-visible-modal\" /\u003e\n    \u003c/View\u003e\n  \u003c/Modal\u003e,\n);\n\n// Children elements of not visible modals are not rendered.\nexpect(queryByTestId('view-within-modal')).toBeNull();\n```\n\n```javascript\nconst { getByTestId } = render(\u003cModal testID=\"not-visible-modal\" visible={false} /\u003e);\n\nexpect(getByTestId('not-visible-modal')).not.toBeVisible();\n```\n\n```javascript\nconst { getByTestId } = render(\u003cView testID=\"test\" accessibilityElementsHidden /\u003e);\n\nexpect(getByTestId('test')).not.toBeVisible();\n```\n\n```javascript\nconst { getByTestId } = render(\n  \u003cView testID=\"test\" importantForAccessibility=\"no-hide-descendants\" /\u003e,\n);\n\nexpect(getByTestId('test')).not.toBeVisible();\n```\n\n### `toHaveAccessibilityState`\n\n```ts\ntoHaveAccessibilityState(state: {\n  disabled?: boolean;\n  selected?: boolean;\n  checked?: boolean | 'mixed';\n  busy?: boolean;\n  expanded?: boolean;\n});\n```\n\nCheck that the element has given accessibility state entries.\n\nThis check is based on `accessibilityState` prop but also takes into account the default entries\nwhich have been found by experimenting with accessibility inspector and screen readers on both iOS\nand Android.\n\nSome state entries behave as if explicit `false` value is the same as not having given state entry,\nso their default value is `false`:\n\n- `disabled`\n- `selected`\n- `busy`\n\nThe remaining state entries behave as if explicit `false` value is different than not having given\nstate entry, so their default value is `undefined`:\n\n- `checked`\n- `expanded`\n\nThis matcher is compatible with `*ByRole` and `*ByA11State` queries from React Native Testing\nLibrary.\n\n#### Examples\n\n```js\nrender(\u003cView testID=\"view\" accessibilityState={{ expanded: true, checked: true }} /\u003e);\n\n// Single value match\nexpect(screen.getByTestId('view')).toHaveAccessibilityState({ expanded: true });\nexpect(screen.getByTestId('view')).toHaveAccessibilityState({ checked: true });\n\n// Can match multiple entries\nexpect(screen.getByTestId('view')).toHaveAccessibilityState({ expanded: true, checked: true });\n```\n\nDefault values handling:\n\n```js\nrender(\u003cView testID=\"view\" /\u003e);\n\n// Matching states where default value is `false`\nexpect(screen.getByTestId('view')).toHaveAccessibilityState({ disabled: false });\nexpect(screen.getByTestId('view')).toHaveAccessibilityState({ selected: false });\nexpect(screen.getByTestId('view')).toHaveAccessibilityState({ busy: false });\n\n// Matching states where default value is `undefined`\nexpect(screen.getByTestId('view')).not.toHaveAccessibilityState({ checked: false });\nexpect(screen.getByTestId('view')).not.toHaveAccessibilityState({ expanded: false });\n```\n\n### `toHaveAccessibilityValue`\n\n```ts\ntoHaveAccessibilityValue(value: {\n  min?: number;\n  max?: number;\n  now?: number;\n  text?: string | RegExp;\n});\n```\n\nCheck that the element has given `accessibilityValue` prop entries.\n\nThis matcher is compatible with `*ByRole` and `*ByA11Value` queries from React Native Testing\nLibrary.\n\n#### Examples\n\n```js\nrender(\u003cView testID=\"view\" accessibilityValue={{ min: 0, max: 100, now: 65 }} /\u003e);\n\nconst view = screen.getByTestId('view');\n\n// Single value match\nexpect(view).toHaveAccessibilityValue({ now: 65 });\nexpect(view).toHaveAccessibilityValue({ max: 0 });\n\n// Can match multiple entries\nexpect(view).toHaveAccessibilityValue({ min: 0, max: 100 });\nexpect(view).toHaveAccessibilityValue({ min: 0, max: 100, now: 65 });\n\n// All specified entries need to match\nexpect(view).not.toHaveAccessibilityValue({ now: 45 });\nexpect(view).not.toHaveAccessibilityValue({ min: 20, max: 100, now: 65 });\n```\n\n```js\nrender(\u003cView testID=\"view\" accessibilityValue={{ text: 'Almost full' }} /\u003e);\n\nconst view = screen.getByTestId('view');\nexpect(view).toHaveAccessibilityValue({ text: 'Almost full' });\nexpect(view).toHaveAccessibilityValue({ text: /full/ });\n```\n\n## Inspiration\n\nThis library was made to be a companion for\n[React Native Testing Library](https://github.com/callstack/react-native-testing-library).\n\nIt was inspired by [jest-dom](https://github.com/gnapse/jest-dom/), the companion library for\n[DTL](https://github.com/kentcdodds/dom-testing-library/). We emulated as many of those helpers as\nwe could while keeping in mind the guiding principles.\n\n## Other solutions\n\nNone known, [you can add the first](http://makeapullrequest.com)!\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/bcarroll22\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/11020406?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eBrandon Carroll\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/testing-library/jest-native/commits?author=bcarroll22\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/testing-library/jest-native/commits?author=bcarroll22\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"#infra-bcarroll22\" title=\"Infrastructure (Hosting, Build-Tools, etc)\"\u003e🚇\u003c/a\u003e \u003ca href=\"https://github.com/testing-library/jest-native/commits?author=bcarroll22\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://santiagomartin.dev\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/7255298?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eSanti\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/testing-library/jest-native/commits?author=SantiMA10\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/marnusw\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/971499?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eMarnus Weststrate\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/testing-library/jest-native/commits?author=marnusw\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/Shywim\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/1584563?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eMatthieu Harlé\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/testing-library/jest-native/commits?author=Shywim\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/acatalina\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/23233812?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAlvaro Catalina\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/testing-library/jest-native/commits?author=acatalina\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://www.ilkeryilmaz.com\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/1588236?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eilker Yılmaz\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/testing-library/jest-native/commits?author=ilkeryilmaz\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/donovanhiland\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/17991396?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eDonovan Hiland\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/testing-library/jest-native/commits?author=donovanhiland\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/testing-library/jest-native/commits?author=donovanhiland\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-enable --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors)\nspecification. Contributions of any kind welcome!\n","funding_links":[],"categories":["JavaScript","Packages","TypeScript"],"sub_categories":["Matchers"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftesting-library%2Fjest-native","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftesting-library%2Fjest-native","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftesting-library%2Fjest-native/lists"}