@testing-library/react-native 12.5.1 → 12.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  height="80"
5
5
  width="80"
6
6
  alt="owl"
7
- src="https://raw.githubusercontent.com/callstack/react-native-testing-library/main/website/static/img/owl.png"
7
+ src="https://raw.githubusercontent.com/callstack/react-native-testing-library/main/website/docs/public/img/owl.png"
8
8
  />
9
9
  <p>Developer-friendly and complete React Native testing utilities that encourage good testing practices.</P>
10
10
  </div>
@@ -89,32 +89,34 @@ You can find the source of `QuestionsBoard` component and this example [here](ht
89
89
 
90
90
  React Native Testing Library consists of following APIs:
91
91
 
92
- - [`render` function](https://callstack.github.io/react-native-testing-library/docs/render) - render your UI components for testing purposes
93
- - [`screen` object](https://callstack.github.io/react-native-testing-library/docs/screen) - access rendered UI:
94
- - [Queries](https://callstack.github.io/react-native-testing-library/docs/queries) - find rendered components by various predicates: role, text, test ids, etc
95
- - Lifecycle methods: [`rerender`](https://callstack.github.io/react-native-testing-library/docs/screen#rerender), [`unmount`](https://callstack.github.io/react-native-testing-library/docs/screen#unmount)
96
- - Helpers: [`debug`](https://callstack.github.io/react-native-testing-library/docs/screen#debug), [`toJSON`](https://callstack.github.io/react-native-testing-library/docs/screen#tojson), [`root`](https://callstack.github.io/react-native-testing-library/docs/screen#root)
97
- - [Jest matchers](https://callstack.github.io/react-native-testing-library/docs/jest-matchers) - validate assumptions about your UI
98
- - [User Event](https://callstack.github.io/react-native-testing-library/docs/user-event) - simulate common user interactions like [`press`](https://callstack.github.io/react-native-testing-library/docs/user-event#press) or [`type`](https://callstack.github.io/react-native-testing-library/docs/user-event#type) in a realistic way
99
- - [Fire Event](https://callstack.github.io/react-native-testing-library/docs/fire-event) - simulate any component event in a simplified way
100
- - [`renderHook` function](https://callstack.github.io/react-native-testing-library/docs/render-hook) - render hooks for testing purposes
101
- - [Other APIs](https://callstack.github.io/react-native-testing-library/docs/other):
102
- - [Async utils](https://callstack.github.io/react-native-testing-library/docs/other#async-utilities): `findBy*` queries, `waitFor`, `waitForElementToBeRemoved`
103
- - [Configuration](https://callstack.github.io/react-native-testing-library/docs/other#configuration): `configure`, `resetToDefaults`
104
- - [Accessibility](https://callstack.github.io/react-native-testing-library/docs/other#accessibility): `isHiddenFromAccessibility`
105
- - [Other](https://callstack.github.io/react-native-testing-library/docs/other#other-helpers): `within`, `act`, `cleanup`
92
+ - [`render` function](https://callstack.github.io/react-native-testing-library/docs/api/render) - render your UI components for testing purposes
93
+ - [`screen` object](https://callstack.github.io/react-native-testing-library/docs/api/screen) - access rendered UI:
94
+ - [Queries](https://callstack.github.io/react-native-testing-library/docs/api/queries) - find rendered components by various predicates: role, text, test ids, etc
95
+ - 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)
96
+ - 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)
97
+ - [Jest matchers](https://callstack.github.io/react-native-testing-library/docs/api/jest-matchers) - validate assumptions about your UI
98
+ - [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
99
+ - [Fire Event](https://callstack.github.io/react-native-testing-library/docs/api/events/fire-event) - simulate any component event in a simplified way
100
+ - [`renderHook` function](https://callstack.github.io/react-native-testing-library/docs/api/misc/render-hook) - render hooks for testing purposes
101
+ - Miscellaneous APIs:
102
+ - [Async utils](https://callstack.github.io/react-native-testing-library/docs/api/misc/async): `findBy*` queries, `waitFor`, `waitForElementToBeRemoved`
103
+ - [Configuration](https://callstack.github.io/react-native-testing-library/docs/api/misc/config): `configure`, `resetToDefaults`
104
+ - [Accessibility](https://callstack.github.io/react-native-testing-library/docs/api/misc/accessibility): `isHiddenFromAccessibility`
105
+ - [Other](https://callstack.github.io/react-native-testing-library/docs/api/misc/other): `within`, `act`, `cleanup`
106
106
 
107
107
  ## Migration Guides
108
108
 
109
- - [Migration to 12.0](https://callstack.github.io/react-native-testing-library/docs/migration-v12)
109
+ - [Migration to 12.0](https://callstack.github.io/react-native-testing-library/docs/migration/v12)
110
+ - [Migration to built-in Jest Matchers](https://callstack.github.io/react-native-testing-library/docs/migration/jest-matchers)
111
+
110
112
 
111
113
  ## Troubleshooting
112
114
 
113
- - [Troubleshooting guide](https://callstack.github.io/react-native-testing-library/docs/troubleshooting)
115
+ - [Troubleshooting guide](https://callstack.github.io/react-native-testing-library/docs/guides/troubleshooting)
114
116
 
115
117
  ## Community Resources
116
118
 
117
- Check out our list of [Community Resources about RNTL](https://callstack.github.io/react-native-testing-library/docs/community-resources).
119
+ Check out our list of [Community Resources about RNTL](https://callstack.github.io/react-native-testing-library/docs/guides/community-resources).
118
120
 
119
121
  ## Made with ❤️ at Callstack
120
122
 
@@ -46,11 +46,7 @@ function isElementVisible(element, accessibilityCache) {
46
46
  return isElementVisible(hostParent, cache);
47
47
  }
48
48
  function isHiddenForStyles(element) {
49
- const style = element.props.style ?? {};
50
- const {
51
- display,
52
- opacity
53
- } = _reactNative.StyleSheet.flatten(style);
54
- return display === 'none' || opacity === 0;
49
+ const flatStyle = _reactNative.StyleSheet.flatten(element.props.style);
50
+ return flatStyle?.display === 'none' || flatStyle?.opacity === 0;
55
51
  }
56
52
  //# sourceMappingURL=to-be-visible.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"to-be-visible.js","names":["_jestMatcherUtils","require","_reactNative","_accessibility","_componentTree","_hostComponentNames","_utils","toBeVisible","element","isNot","checkHostElement","pass","isElementVisible","message","is","matcherHint","formatElement","join","accessibilityCache","cache","WeakMap","isHiddenFromAccessibility","isHiddenForStyles","isHostModal","props","visible","hostParent","getHostParent","style","display","opacity","StyleSheet","flatten"],"sources":["../../src/matchers/to-be-visible.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { StyleSheet } from 'react-native';\nimport { isHiddenFromAccessibility } from '../helpers/accessibility';\nimport { getHostParent } from '../helpers/component-tree';\nimport { isHostModal } from '../helpers/host-component-names';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeVisible(this: jest.MatcherContext, element: ReactTestInstance) {\n if (element !== null || !this.isNot) {\n checkHostElement(element, toBeVisible, this);\n }\n\n return {\n pass: isElementVisible(element),\n message: () => {\n const is = this.isNot ? 'is' : 'is not';\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBeVisible`, 'element', ''),\n '',\n `Received element ${is} visible:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n\nfunction isElementVisible(\n element: ReactTestInstance,\n accessibilityCache?: WeakMap<ReactTestInstance, boolean>,\n): boolean {\n // Use cache to speed up repeated searches by `isHiddenFromAccessibility`.\n const cache = accessibilityCache ?? new WeakMap<ReactTestInstance, boolean>();\n if (isHiddenFromAccessibility(element, { cache })) {\n return false;\n }\n\n if (isHiddenForStyles(element)) {\n return false;\n }\n\n // Note: this seems to be a bug in React Native.\n // PR with fix: https://github.com/facebook/react-native/pull/39157\n if (isHostModal(element) && element.props.visible === false) {\n return false;\n }\n\n const hostParent = getHostParent(element);\n if (hostParent === null) {\n return true;\n }\n\n return isElementVisible(hostParent, cache);\n}\n\nfunction isHiddenForStyles(element: ReactTestInstance) {\n const style = element.props.style ?? {};\n const { display, opacity } = StyleSheet.flatten(style);\n return display === 'none' || opacity === 0;\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI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ACc,UAAU,EAAEP,KAAK,CAAC;AAC5C;AAEA,SAASG,iBAAiBA,CAACd,OAA0B,EAAE;EACrD,MAAMoB,KAAK,GAAGpB,OAAO,CAACgB,KAAK,CAACI,KAAK,IAAI,CAAC,CAAC;EACvC,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAGC,uBAAU,CAACC,OAAO,CAACJ,KAAK,CAAC;EACtD,OAAOC,OAAO,KAAK,MAAM,IAAIC,OAAO,KAAK,CAAC;AAC5C","ignoreList":[]}
1
+ {"version":3,"file":"to-be-visible.js","names":["_jestMatcherUtils","require","_reactNative","_accessibility","_componentTree","_hostComponentNames","_utils","toBeVisible","element","isNot","checkHostElement","pass","isElementVisible","message","is","matcherHint","formatElement","join","accessibilityCache","cache","WeakMap","isHiddenFromAccessibility","isHiddenForStyles","isHostModal","props","visible","hostParent","getHostParent","flatStyle","StyleSheet","flatten","style","display","opacity"],"sources":["../../src/matchers/to-be-visible.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { StyleSheet } from 'react-native';\nimport { isHiddenFromAccessibility } from '../helpers/accessibility';\nimport { getHostParent } from '../helpers/component-tree';\nimport { isHostModal } from '../helpers/host-component-names';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeVisible(this: jest.MatcherContext, element: ReactTestInstance) {\n if (element !== null || !this.isNot) {\n checkHostElement(element, toBeVisible, this);\n }\n\n return {\n pass: isElementVisible(element),\n message: () => {\n const is = this.isNot ? 'is' : 'is not';\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBeVisible`, 'element', ''),\n '',\n `Received element ${is} visible:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n\nfunction isElementVisible(\n element: ReactTestInstance,\n accessibilityCache?: WeakMap<ReactTestInstance, boolean>,\n): boolean {\n // Use cache to speed up repeated searches by `isHiddenFromAccessibility`.\n const cache = accessibilityCache ?? new WeakMap<ReactTestInstance, boolean>();\n if (isHiddenFromAccessibility(element, { cache })) {\n return false;\n }\n\n if (isHiddenForStyles(element)) {\n return false;\n }\n\n // Note: this seems to be a bug in React Native.\n // PR with fix: https://github.com/facebook/react-native/pull/39157\n if (isHostModal(element) && element.props.visible === false) {\n return false;\n }\n\n const hostParent = getHostParent(element);\n if (hostParent === null) {\n return true;\n }\n\n return isElementVisible(hostParent, cache);\n}\n\nfunction isHiddenForStyles(element: ReactTestInstance) {\n const flatStyle = StyleSheet.flatten(element.props.style);\n return flatStyle?.display === 'none' || flatStyle?.opacity === 0;\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAEO,SAASM,WAAWA,CAA4BC,OAA0B,EAAE;EACjF,IAAIA,OAAO,KAAK,IAAI,IAAI,CAAC,IAAI,CAACC,KAAK,EAAE;IACnC,IAAAC,uBAAgB,EAACF,OAAO,EAAED,WAAW,EAAE,IAAI,CAAC;EAC9C;EAEA,OAAO;IACLI,IAAI,EAAEC,gBAAgB,CAACJ,OAAO,CAAC;IAC/BK,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACL,KAAK,GAAG,IAAI,GAAG,QAAQ;MACvC,OAAO,CACL,IAAAM,6BAAW,EAAE,GAAE,IAAI,CAACN,KAAK,GAAG,MAAM,GAAG,EAAG,cAAa,EAAE,SAAS,EAAE,EAAE,CAAC,EACrE,EAAE,EACD,oBAAmBK,EAAG,WAAU,EACjC,IAAAE,oBAAa,EAACR,OAAO,CAAC,CACvB,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH;AAEA,SAASL,gBAAgBA,CACvBJ,OAA0B,EAC1BU,kBAAwD,EAC/C;EACT;EACA,MAAMC,KAAK,GAAGD,kBAAkB,IAAI,IAAIE,OAAO,CAA6B,CAAC;EAC7E,IAAI,IAAAC,wCAAyB,EAACb,OAAO,EAAE;IAAEW;EAAM,CAAC,CAAC,EAAE;IACjD,OAAO,KAAK;EACd;EAEA,IAAIG,iBAAiB,CAACd,OAAO,CAAC,EAAE;IAC9B,OAAO,KAAK;EACd;;EAEA;EACA;EACA,IAAI,IAAAe,+BAAW,EAACf,OAAO,CAAC,IAAIA,OAAO,CAACgB,KAAK,CAACC,OAAO,KAAK,KAAK,EAAE;IAC3D,OAAO,KAAK;EACd;EAEA,MAAMC,UAAU,GAAG,IAAAC,4BAAa,EAACnB,OAAO,CAAC;EACzC,IAAIkB,UAAU,KAAK,IAAI,EAAE;IACvB,OAAO,IAAI;EACb;EAEA,OAAOd,gBAAgB,CAACc,UAAU,EAAEP,KAAK,CAAC;AAC5C;AAEA,SAASG,iBAAiBA,CAACd,OAA0B,EAAE;EACrD,MAAMoB,SAAS,GAAGC,uBAAU,CAACC,OAAO,CAACtB,OAAO,CAACgB,KAAK,CAACO,KAAK,CAAC;EACzD,OAAOH,SAAS,EAAEI,OAAO,KAAK,MAAM,IAAIJ,SAAS,EAAEK,OAAO,KAAK,CAAC;AAClE","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/react-native",
3
- "version": "12.5.1",
3
+ "version": "12.5.2",
4
4
  "description": "Simple and complete React Native testing utilities that encourage good testing practices.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",