@testing-library/react-native 11.3.0 → 11.5.0

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.
Files changed (126) hide show
  1. package/README.md +5 -2
  2. package/build/act.js +9 -15
  3. package/build/act.js.map +1 -1
  4. package/build/cleanup.d.ts +1 -1
  5. package/build/cleanup.js +0 -4
  6. package/build/cleanup.js.map +1 -1
  7. package/build/config.d.ts +15 -2
  8. package/build/config.js +16 -8
  9. package/build/config.js.map +1 -1
  10. package/build/fireEvent.js +3 -31
  11. package/build/fireEvent.js.map +1 -1
  12. package/build/flushMicroTasks.d.ts +1 -1
  13. package/build/flushMicroTasks.js +0 -3
  14. package/build/flushMicroTasks.js.map +1 -1
  15. package/build/helpers/accessiblity.d.ts +10 -1
  16. package/build/helpers/accessiblity.js +28 -24
  17. package/build/helpers/accessiblity.js.map +1 -1
  18. package/build/helpers/component-tree.js +6 -27
  19. package/build/helpers/component-tree.js.map +1 -1
  20. package/build/helpers/debugDeep.d.ts +5 -1
  21. package/build/helpers/debugDeep.js +7 -6
  22. package/build/helpers/debugDeep.js.map +1 -1
  23. package/build/helpers/debugShallow.js +0 -5
  24. package/build/helpers/debugShallow.js.map +1 -1
  25. package/build/helpers/errors.js +4 -25
  26. package/build/helpers/errors.js.map +1 -1
  27. package/build/helpers/filterNodeByType.js +0 -2
  28. package/build/helpers/filterNodeByType.js.map +1 -1
  29. package/build/helpers/findAll.d.ts +10 -0
  30. package/build/helpers/findAll.js +44 -0
  31. package/build/helpers/findAll.js.map +1 -0
  32. package/build/helpers/format.d.ts +5 -1
  33. package/build/helpers/format.js +17 -7
  34. package/build/helpers/format.js.map +1 -1
  35. package/build/helpers/getTextContent.d.ts +2 -0
  36. package/build/helpers/getTextContent.js +20 -0
  37. package/build/helpers/getTextContent.js.map +1 -0
  38. package/build/helpers/matchers/accessibilityState.d.ts +3 -0
  39. package/build/helpers/matchers/accessibilityState.js +28 -0
  40. package/build/helpers/matchers/accessibilityState.js.map +1 -0
  41. package/build/helpers/matchers/accessibilityValue.d.ts +9 -0
  42. package/build/helpers/matchers/accessibilityValue.js +12 -0
  43. package/build/helpers/matchers/accessibilityValue.js.map +1 -0
  44. package/build/helpers/matchers/matchArrayProp.js +0 -3
  45. package/build/helpers/matchers/matchArrayProp.js.map +1 -1
  46. package/build/helpers/matchers/matchObjectProp.js +0 -2
  47. package/build/helpers/matchers/matchObjectProp.js.map +1 -1
  48. package/build/helpers/matchers/matchStringProp.js +0 -3
  49. package/build/helpers/matchers/matchStringProp.js.map +1 -1
  50. package/build/helpers/matchers/matchTextContent.d.ts +3 -0
  51. package/build/helpers/matchers/matchTextContent.js +22 -0
  52. package/build/helpers/matchers/matchTextContent.js.map +1 -0
  53. package/build/helpers/stringValidation.js +0 -7
  54. package/build/helpers/stringValidation.js.map +1 -1
  55. package/build/helpers/timers.js +10 -21
  56. package/build/helpers/timers.js.map +1 -1
  57. package/build/index.flow.js +169 -56
  58. package/build/index.js +0 -6
  59. package/build/index.js.map +1 -1
  60. package/build/matches.d.ts +7 -3
  61. package/build/matches.js +2 -4
  62. package/build/matches.js.map +1 -1
  63. package/build/pure.d.ts +12 -23
  64. package/build/pure.js +8 -15
  65. package/build/pure.js.map +1 -1
  66. package/build/queries/a11yState.d.ts +15 -14
  67. package/build/queries/a11yState.js +16 -13
  68. package/build/queries/a11yState.js.map +1 -1
  69. package/build/queries/a11yValue.d.ts +15 -20
  70. package/build/queries/a11yValue.js +16 -13
  71. package/build/queries/a11yValue.js.map +1 -1
  72. package/build/queries/displayValue.d.ts +11 -9
  73. package/build/queries/displayValue.js +2 -12
  74. package/build/queries/displayValue.js.map +1 -1
  75. package/build/queries/hintText.d.ts +23 -20
  76. package/build/queries/hintText.js +11 -11
  77. package/build/queries/hintText.js.map +1 -1
  78. package/build/queries/labelText.d.ts +11 -8
  79. package/build/queries/labelText.js +11 -11
  80. package/build/queries/labelText.js.map +1 -1
  81. package/build/queries/makeQueries.d.ts +9 -9
  82. package/build/queries/makeQueries.js +40 -24
  83. package/build/queries/makeQueries.js.map +1 -1
  84. package/build/queries/options.d.ts +11 -0
  85. package/build/queries/options.js +2 -0
  86. package/build/queries/options.js.map +1 -0
  87. package/build/queries/placeholderText.d.ts +11 -9
  88. package/build/queries/placeholderText.js +2 -12
  89. package/build/queries/placeholderText.js.map +1 -1
  90. package/build/queries/role.d.ts +7 -3
  91. package/build/queries/role.js +32 -13
  92. package/build/queries/role.js.map +1 -1
  93. package/build/queries/testId.d.ts +11 -9
  94. package/build/queries/testId.js +3 -11
  95. package/build/queries/testId.js.map +1 -1
  96. package/build/queries/text.d.ts +11 -13
  97. package/build/queries/text.js +6 -71
  98. package/build/queries/text.js.map +1 -1
  99. package/build/queries/unsafeProps.d.ts +1 -1
  100. package/build/queries/unsafeProps.js +2 -11
  101. package/build/queries/unsafeProps.js.map +1 -1
  102. package/build/queries/unsafeType.d.ts +1 -1
  103. package/build/queries/unsafeType.js +2 -9
  104. package/build/queries/unsafeType.js.map +1 -1
  105. package/build/react-versions.js +0 -4
  106. package/build/react-versions.js.map +1 -1
  107. package/build/render.d.ts +88 -141
  108. package/build/render.js +21 -31
  109. package/build/render.js.map +1 -1
  110. package/build/renderHook.d.ts +2 -2
  111. package/build/renderHook.js +2 -12
  112. package/build/renderHook.js.map +1 -1
  113. package/build/screen.js +0 -6
  114. package/build/screen.js.map +1 -1
  115. package/build/shallow.js +0 -6
  116. package/build/shallow.js.map +1 -1
  117. package/build/waitFor.d.ts +1 -1
  118. package/build/waitFor.js +29 -52
  119. package/build/waitFor.js.map +1 -1
  120. package/build/waitForElementToBeRemoved.js +2 -11
  121. package/build/waitForElementToBeRemoved.js.map +1 -1
  122. package/build/within.d.ts +84 -138
  123. package/build/within.js +2 -14
  124. package/build/within.js.map +1 -1
  125. package/package.json +12 -11
  126. package/typings/index.flow.js +169 -56
@@ -11,7 +11,6 @@ exports.getHostSelves = getHostSelves;
11
11
  exports.getHostSiblings = getHostSiblings;
12
12
  exports.isHostElement = isHostElement;
13
13
  exports.isHostElementForType = isHostElementForType;
14
-
15
14
  /**
16
15
  * Checks if the given element is a host element.
17
16
  * @param element The element to check.
@@ -19,46 +18,38 @@ exports.isHostElementForType = isHostElementForType;
19
18
  function isHostElement(element) {
20
19
  return typeof element?.type === 'string';
21
20
  }
21
+
22
22
  /**
23
23
  * Returns first host ancestor for given element.
24
24
  * @param element The element start traversing from.
25
25
  */
26
-
27
-
28
26
  function getHostParent(element) {
29
27
  if (element == null) {
30
28
  return null;
31
29
  }
32
-
33
30
  let current = element.parent;
34
-
35
31
  while (current) {
36
32
  if (isHostElement(current)) {
37
33
  return current;
38
34
  }
39
-
40
35
  current = current.parent;
41
36
  }
42
-
43
37
  return null;
44
38
  }
39
+
45
40
  /**
46
41
  * Returns host children for given element.
47
42
  * @param element The element start traversing from.
48
43
  */
49
-
50
-
51
44
  function getHostChildren(element) {
52
45
  if (element == null) {
53
46
  return [];
54
47
  }
55
-
56
48
  const hostChildren = [];
57
49
  element.children.forEach(child => {
58
50
  if (typeof child !== 'object') {
59
51
  return;
60
52
  }
61
-
62
53
  if (isHostElement(child)) {
63
54
  hostChildren.push(child);
64
55
  } else {
@@ -67,6 +58,7 @@ function getHostChildren(element) {
67
58
  });
68
59
  return hostChildren;
69
60
  }
61
+
70
62
  /**
71
63
  * Return a single host element that represent the passed host or composite element.
72
64
  *
@@ -75,21 +67,17 @@ function getHostChildren(element) {
75
67
  * @returns If the passed element is a host element, it will return itself, if the passed element is a composite
76
68
  * element, it will return a single host descendant.
77
69
  */
78
-
79
-
80
70
  function getHostSelf(element) {
81
71
  const hostSelves = getHostSelves(element);
82
-
83
72
  if (hostSelves.length === 0) {
84
73
  throw new Error(`Expected exactly one host element, but found none.`);
85
74
  }
86
-
87
75
  if (hostSelves.length > 1) {
88
76
  throw new Error(`Expected exactly one host element, but found ${hostSelves.length}.`);
89
77
  }
90
-
91
78
  return hostSelves[0];
92
79
  }
80
+
93
81
  /**
94
82
  * Return the array of host elements that represent the passed element.
95
83
  *
@@ -97,46 +85,37 @@ function getHostSelf(element) {
97
85
  * @returns If the passed element is a host element, it will return an array containing only that element,
98
86
  * if the passed element is a composite element, it will return an array containing its host children (zero, one or many).
99
87
  */
100
-
101
-
102
88
  function getHostSelves(element) {
103
89
  return typeof element?.type === 'string' ? [element] : getHostChildren(element);
104
90
  }
91
+
105
92
  /**
106
93
  * Returns host siblings for given element.
107
94
  * @param element The element start traversing from.
108
95
  */
109
-
110
-
111
96
  function getHostSiblings(element) {
112
97
  const hostParent = getHostParent(element);
113
98
  const hostSelves = getHostSelves(element);
114
99
  return getHostChildren(hostParent).filter(sibling => !hostSelves.includes(sibling));
115
100
  }
116
-
117
101
  function getCompositeParentOfType(element, type) {
118
102
  let current = element.parent;
119
-
120
103
  while (!isHostElement(current)) {
121
104
  // We're at the root of the tree
122
105
  if (!current) {
123
106
  return null;
124
107
  }
125
-
126
108
  if (current.type === type) {
127
109
  return current;
128
110
  }
129
-
130
111
  current = current.parent;
131
112
  }
132
-
133
113
  return null;
134
114
  }
115
+
135
116
  /**
136
117
  * Note: this function should be generally used for core React Native types like `View`, `Text`, `TextInput`, etc.
137
118
  */
138
-
139
-
140
119
  function isHostElementForType(element, type) {
141
120
  // Not a host element
142
121
  if (!isHostElement(element)) return false;
@@ -1 +1 @@
1
- {"version":3,"file":"component-tree.js","names":["isHostElement","element","type","getHostParent","current","parent","getHostChildren","hostChildren","children","forEach","child","push","getHostSelf","hostSelves","getHostSelves","length","Error","getHostSiblings","hostParent","filter","sibling","includes","getCompositeParentOfType","isHostElementForType"],"sources":["../../src/helpers/component-tree.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\n\n/**\n * Checks if the given element is a host element.\n * @param element The element to check.\n */\nexport function isHostElement(element?: ReactTestInstance | null): boolean {\n return typeof element?.type === 'string';\n}\n\n/**\n * Returns first host ancestor for given element.\n * @param element The element start traversing from.\n */\nexport function getHostParent(\n element: ReactTestInstance | null\n): ReactTestInstance | null {\n if (element == null) {\n return null;\n }\n\n let current = element.parent;\n while (current) {\n if (isHostElement(current)) {\n return current;\n }\n\n current = current.parent;\n }\n\n return null;\n}\n\n/**\n * Returns host children for given element.\n * @param element The element start traversing from.\n */\nexport function getHostChildren(\n element: ReactTestInstance | null\n): ReactTestInstance[] {\n if (element == null) {\n return [];\n }\n\n const hostChildren: ReactTestInstance[] = [];\n\n element.children.forEach((child) => {\n if (typeof child !== 'object') {\n return;\n }\n\n if (isHostElement(child)) {\n hostChildren.push(child);\n } else {\n hostChildren.push(...getHostChildren(child));\n }\n });\n\n return hostChildren;\n}\n\n/**\n * Return a single host element that represent the passed host or composite element.\n *\n * @param element The element start traversing from.\n * @throws Error if the passed element is a composite element and has no host children or has more than one host child.\n * @returns If the passed element is a host element, it will return itself, if the passed element is a composite\n * element, it will return a single host descendant.\n */\nexport function getHostSelf(\n element: ReactTestInstance | null\n): ReactTestInstance {\n const hostSelves = getHostSelves(element);\n\n if (hostSelves.length === 0) {\n throw new Error(`Expected exactly one host element, but found none.`);\n }\n\n if (hostSelves.length > 1) {\n throw new Error(\n `Expected exactly one host element, but found ${hostSelves.length}.`\n );\n }\n\n return hostSelves[0];\n}\n\n/**\n * Return the array of host elements that represent the passed element.\n *\n * @param element The element start traversing from.\n * @returns If the passed element is a host element, it will return an array containing only that element,\n * if the passed element is a composite element, it will return an array containing its host children (zero, one or many).\n */\nexport function getHostSelves(\n element: ReactTestInstance | null\n): ReactTestInstance[] {\n return typeof element?.type === 'string'\n ? [element]\n : getHostChildren(element);\n}\n\n/**\n * Returns host siblings for given element.\n * @param element The element start traversing from.\n */\nexport function getHostSiblings(\n element: ReactTestInstance | null\n): ReactTestInstance[] {\n const hostParent = getHostParent(element);\n const hostSelves = getHostSelves(element);\n return getHostChildren(hostParent).filter(\n (sibling) => !hostSelves.includes(sibling)\n );\n}\n\nexport function getCompositeParentOfType(\n element: ReactTestInstance,\n type: React.ComponentType\n) {\n let current = element.parent;\n\n while (!isHostElement(current)) {\n // We're at the root of the tree\n if (!current) {\n return null;\n }\n\n if (current.type === type) {\n return current;\n }\n current = current.parent;\n }\n\n return null;\n}\n\n/**\n * Note: this function should be generally used for core React Native types like `View`, `Text`, `TextInput`, etc.\n */\nexport function isHostElementForType(\n element: ReactTestInstance,\n type: React.ComponentType\n) {\n // Not a host element\n if (!isHostElement(element)) return false;\n\n return getCompositeParentOfType(element, type) !== null;\n}\n"],"mappings":";;;;;;;;;;;;;;AAEA;AACA;AACA;AACA;AACO,SAASA,aAAT,CAAuBC,OAAvB,EAAoE;EACzE,OAAO,OAAOA,OAAO,EAAEC,IAAhB,KAAyB,QAAhC;AACD;AAED;AACA;AACA;AACA;;;AACO,SAASC,aAAT,CACLF,OADK,EAEqB;EAC1B,IAAIA,OAAO,IAAI,IAAf,EAAqB;IACnB,OAAO,IAAP;EACD;;EAED,IAAIG,OAAO,GAAGH,OAAO,CAACI,MAAtB;;EACA,OAAOD,OAAP,EAAgB;IACd,IAAIJ,aAAa,CAACI,OAAD,CAAjB,EAA4B;MAC1B,OAAOA,OAAP;IACD;;IAEDA,OAAO,GAAGA,OAAO,CAACC,MAAlB;EACD;;EAED,OAAO,IAAP;AACD;AAED;AACA;AACA;AACA;;;AACO,SAASC,eAAT,CACLL,OADK,EAEgB;EACrB,IAAIA,OAAO,IAAI,IAAf,EAAqB;IACnB,OAAO,EAAP;EACD;;EAED,MAAMM,YAAiC,GAAG,EAA1C;EAEAN,OAAO,CAACO,QAAR,CAAiBC,OAAjB,CAA0BC,KAAD,IAAW;IAClC,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;MAC7B;IACD;;IAED,IAAIV,aAAa,CAACU,KAAD,CAAjB,EAA0B;MACxBH,YAAY,CAACI,IAAb,CAAkBD,KAAlB;IACD,CAFD,MAEO;MACLH,YAAY,CAACI,IAAb,CAAkB,GAAGL,eAAe,CAACI,KAAD,CAApC;IACD;EACF,CAVD;EAYA,OAAOH,YAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA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BAAT,CACLtB,OADK,EAELC,IAFK,EAGL;EACA;EACA,IAAI,CAACF,aAAa,CAACC,OAAD,CAAlB,EAA6B,OAAO,KAAP;EAE7B,OAAOqB,wBAAwB,CAACrB,OAAD,EAAUC,IAAV,CAAxB,KAA4C,IAAnD;AACD"}
1
+ {"version":3,"file":"component-tree.js","names":["isHostElement","element","type","getHostParent","current","parent","getHostChildren","hostChildren","children","forEach","child","push","getHostSelf","hostSelves","getHostSelves","length","Error","getHostSiblings","hostParent","filter","sibling","includes","getCompositeParentOfType","isHostElementForType"],"sources":["../../src/helpers/component-tree.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\n\n/**\n * Checks if the given element is a host element.\n * @param element The element to check.\n */\nexport function isHostElement(element?: ReactTestInstance | null): boolean {\n return typeof element?.type === 'string';\n}\n\n/**\n * Returns first host ancestor for given element.\n * @param element The element start traversing from.\n */\nexport function getHostParent(\n element: ReactTestInstance | null\n): ReactTestInstance | null {\n if (element == null) {\n return null;\n }\n\n let current = element.parent;\n while (current) {\n if (isHostElement(current)) {\n return current;\n }\n\n current = current.parent;\n }\n\n return null;\n}\n\n/**\n * Returns host children for given element.\n * @param element The element start traversing from.\n */\nexport function getHostChildren(\n element: ReactTestInstance | null\n): ReactTestInstance[] {\n if (element == null) {\n return [];\n }\n\n const hostChildren: ReactTestInstance[] = [];\n\n element.children.forEach((child) => {\n if (typeof child !== 'object') {\n return;\n }\n\n if (isHostElement(child)) {\n hostChildren.push(child);\n } else {\n hostChildren.push(...getHostChildren(child));\n }\n });\n\n return hostChildren;\n}\n\n/**\n * Return a single host element that represent the passed host or composite element.\n *\n * @param element The element start traversing from.\n * @throws Error if the passed element is a composite element and has no host children or has more than one host child.\n * @returns If the passed element is a host element, it will return itself, if the passed element is a composite\n * element, it will return a single host descendant.\n */\nexport function getHostSelf(\n element: ReactTestInstance | null\n): ReactTestInstance {\n const hostSelves = getHostSelves(element);\n\n if (hostSelves.length === 0) {\n throw new Error(`Expected exactly one host element, but found none.`);\n }\n\n if (hostSelves.length > 1) {\n throw new Error(\n `Expected exactly one host element, but found ${hostSelves.length}.`\n );\n }\n\n return hostSelves[0];\n}\n\n/**\n * Return the array of host elements that represent the passed element.\n *\n * @param element The element start traversing from.\n * @returns If the passed element is a host element, it will return an array containing only that element,\n * if the passed element is a composite element, it will return an array containing its host children (zero, one or many).\n */\nexport function getHostSelves(\n element: ReactTestInstance | null\n): ReactTestInstance[] {\n return typeof element?.type === 'string'\n ? [element]\n : getHostChildren(element);\n}\n\n/**\n * Returns host siblings for given element.\n * @param element The element start traversing from.\n */\nexport function getHostSiblings(\n element: ReactTestInstance | null\n): ReactTestInstance[] {\n const hostParent = getHostParent(element);\n const hostSelves = getHostSelves(element);\n return getHostChildren(hostParent).filter(\n (sibling) => !hostSelves.includes(sibling)\n );\n}\n\nexport function getCompositeParentOfType(\n element: ReactTestInstance,\n type: React.ComponentType\n) {\n let current = element.parent;\n\n while (!isHostElement(current)) {\n // We're at the root of the tree\n if (!current) {\n return null;\n }\n\n if (current.type === type) {\n return current;\n }\n current = current.parent;\n }\n\n return null;\n}\n\n/**\n * Note: this function should be generally used for core React Native types like `View`, `Text`, `TextInput`, etc.\n */\nexport function isHostElementForType(\n element: ReactTestInstance,\n type: React.ComponentType\n) {\n // Not a host element\n if (!isHostElement(element)) return false;\n\n return getCompositeParentOfType(element, type) !== null;\n}\n"],"mappings":";;;;;;;;;;;;;AAEA;AACA;AACA;AACA;AACO,SAASA,aAAa,CAACC,OAAkC,EAAW;EACzE,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ;AAC1C;;AAEA;AACA;AACA;AACA;AACO,SAASC,aAAa,CAC3BF,OAAiC,EACP;EAC1B,IAAIA,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,IAAI;EACb;EAEA,IAAIG,OAAO,GAAGH,OAAO,CAACI,MAAM;EAC5B,OAAOD,OAAO,EAAE;IACd,IAAIJ,aAAa,CAACI,OAAO,CAAC,EAAE;M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Z;EACrB,MAAMiB,UAAU,GAAGf,aAAa,CAACF,OAAO,CAAC;EACzC,MAAMY,UAAU,GAAGC,aAAa,CAACb,OAAO,CAAC;EACzC,OAAOK,eAAe,CAACY,UAAU,CAAC,CAACC,MAAM,CACtCC,OAAO,IAAK,CAACP,UAAU,CAACQ,QAAQ,CAACD,OAAO,CAAC,CAC3C;AACH;AAEO,SAASE,wBAAwB,CACtCrB,OAA0B,EAC1BC,IAAyB,EACzB;EACA,IAAIE,OAAO,GAAGH,OAAO,CAACI,MAAM;EAE5B,OAAO,CAACL,aAAa,CAACI,OAAO,CAAC,EAAE;IAC9B;IACA,IAAI,CAACA,OAAO,EAAE;MACZ,OAAO,IAAI;IACb;IAEA,IAAIA,OAAO,CAACF,IAAI,KAAKA,IAAI,EAAE;MACzB,OAAOE,OAAO;IAChB;IACAA,OAAO,GAAGA,OAAO,CAACC,MAAM;EAC1B;EAEA,OAAO,IAAI;AACb;;AAEA;AACA;AACA;AACO,SAASkB,oBAAoB,CAClCtB,OAA0B,EAC1BC,IAAyB,EACzB;EACA;EACA,IAAI,CAACF,aAAa,CAACC,OAAO,CAAC,EAAE,OAAO,KAAK;EAEzC,OAAOqB,wBAAwB,CAACrB,OAAO,EAAEC,IAAI,CAAC,KAAK,IAAI;AACzD"}
@@ -1,5 +1,9 @@
1
1
  import type { ReactTestRendererJSON } from 'react-test-renderer';
2
+ import { FormatOptions } from './format';
3
+ export type DebugOptions = {
4
+ message?: string;
5
+ } & FormatOptions;
2
6
  /**
3
7
  * Log pretty-printed deep test component instance
4
8
  */
5
- export default function debugDeep(instance: ReactTestRendererJSON | ReactTestRendererJSON[], message?: string): void;
9
+ export default function debugDeep(instance: ReactTestRendererJSON | ReactTestRendererJSON[], options?: DebugOptions | string): void;
@@ -4,21 +4,22 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = debugDeep;
7
-
8
7
  var _format = _interopRequireDefault(require("./format"));
9
-
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
9
  /**
13
10
  * Log pretty-printed deep test component instance
14
11
  */
15
- function debugDeep(instance, message) {
12
+ function debugDeep(instance, options) {
13
+ const message = typeof options === 'string' ? options : options?.message;
14
+ const formatOptions = typeof options === 'object' ? {
15
+ mapProps: options?.mapProps
16
+ } : undefined;
16
17
  if (message) {
17
18
  // eslint-disable-next-line no-console
18
- console.log(`${message}\n\n`, (0, _format.default)(instance));
19
+ console.log(`${message}\n\n`, (0, _format.default)(instance, formatOptions));
19
20
  } else {
20
21
  // eslint-disable-next-line no-console
21
- console.log((0, _format.default)(instance));
22
+ console.log((0, _format.default)(instance, formatOptions));
22
23
  }
23
24
  }
24
25
  //# sourceMappingURL=debugDeep.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"debugDeep.js","names":["debugDeep","instance","message","console","log","format"],"sources":["../../src/helpers/debugDeep.ts"],"sourcesContent":["import type { ReactTestRendererJSON } from 'react-test-renderer';\nimport format from './format';\n\n/**\n * Log pretty-printed deep test component instance\n */\nexport default function debugDeep(\n instance: ReactTestRendererJSON | ReactTestRendererJSON[],\n message?: string\n) {\n if (message) {\n // eslint-disable-next-line no-console\n console.log(`${message}\\n\\n`, format(instance));\n } else {\n // eslint-disable-next-line no-console\n console.log(format(instance));\n }\n}\n"],"mappings":";;;;;;;AACA;;;;AAEA;AACA;AACA;AACe,SAASA,SAAT,CACbC,QADa,EAEbC,OAFa,EAGb;EACA,IAAIA,OAAJ,EAAa;IACX;IACAC,OAAO,CAACC,GAAR,CAAa,GAAEF,OAAQ,MAAvB,EAA8B,IAAAG,eAAA,EAAOJ,QAAP,CAA9B;EACD,CAHD,MAGO;IACL;IACAE,OAAO,CAACC,GAAR,CAAY,IAAAC,eAAA,EAAOJ,QAAP,CAAZ;EACD;AACF"}
1
+ {"version":3,"file":"debugDeep.js","names":["debugDeep","instance","options","message","formatOptions","mapProps","undefined","console","log","format"],"sources":["../../src/helpers/debugDeep.ts"],"sourcesContent":["import type { ReactTestRendererJSON } from 'react-test-renderer';\nimport format, { FormatOptions } from './format';\n\nexport type DebugOptions = {\n message?: string;\n} & FormatOptions;\n\n/**\n * Log pretty-printed deep test component instance\n */\nexport default function debugDeep(\n instance: ReactTestRendererJSON | ReactTestRendererJSON[],\n options?: DebugOptions | string\n) {\n const message = typeof options === 'string' ? options : options?.message;\n\n const formatOptions =\n typeof options === 'object' ? { mapProps: options?.mapProps } : undefined;\n\n if (message) {\n // eslint-disable-next-line no-console\n console.log(`${message}\\n\\n`, format(instance, formatOptions));\n } else {\n // eslint-disable-next-line no-console\n console.log(format(instance, formatOptions));\n }\n}\n"],"mappings":";;;;;;AACA;AAAiD;AAMjD;AACA;AACA;AACe,SAASA,SAAS,CAC/BC,QAAyD,EACzDC,OAA+B,EAC/B;EACA,MAAMC,OAAO,GAAG,OAAOD,OAAO,KAAK,QAAQ,GAAGA,OAAO,GAAGA,OAAO,EAAEC,OAAO;EAExE,MAAMC,aAAa,GACjB,OAAOF,OAAO,KAAK,QAAQ,GAAG;IAAEG,QAAQ,EAAEH,OAAO,EAAEG;EAAS,CAAC,GAAGC,SAAS;EAE3E,IAAIH,OAAO,EAAE;IACX;IACAI,OAAO,CAACC,GAAG,CAAE,GAAEL,OAAQ,MAAK,EAAE,IAAAM,eAAM,EAACR,QAAQ,EAAEG,aAAa,CAAC,CAAC;EAChE,CAAC,MAAM;IACL;IACAG,OAAO,CAACC,GAAG,CAAC,IAAAC,eAAM,EAACR,QAAQ,EAAEG,aAAa,CAAC,CAAC;EAC9C;AACF"}
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = debugShallow;
7
-
8
7
  var _shallow = require("../shallow");
9
-
10
8
  var _format = _interopRequireDefault(require("./format"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  /**
15
11
  * Log pretty-printed shallow test component instance
16
12
  */
@@ -18,7 +14,6 @@ function debugShallow(instance, message) {
18
14
  const {
19
15
  output
20
16
  } = (0, _shallow.shallowInternal)(instance);
21
-
22
17
  if (message) {
23
18
  // eslint-disable-next-line no-console
24
19
  console.log(`${message}\n\n`, (0, _format.default)(output));
@@ -1 +1 @@
1
- {"version":3,"file":"debugShallow.js","names":["debugShallow","instance","message","output","shallowInternal","console","log","format"],"sources":["../../src/helpers/debugShallow.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ReactTestInstance } from 'react-test-renderer';\nimport { shallowInternal } from '../shallow';\nimport format from './format';\n\n/**\n * Log pretty-printed shallow test component instance\n */\nexport default function debugShallow(\n instance: ReactTestInstance | React.ReactElement<any>,\n message?: string\n) {\n const { output } = shallowInternal(instance);\n\n if (message) {\n // eslint-disable-next-line no-console\n console.log(`${message}\\n\\n`, format(output));\n } else {\n // eslint-disable-next-line no-console\n console.log(format(output));\n }\n}\n"],"mappings":";;;;;;;AAEA;;AACA;;;;AAEA;AACA;AACA;AACe,SAASA,YAAT,CACbC,QADa,EAEbC,OAFa,EAGb;EACA,MAAM;IAAEC;EAAF,IAAa,IAAAC,wBAAA,EAAgBH,QAAhB,CAAnB;;EAEA,IAAIC,OAAJ,EAAa;IACX;IACAG,OAAO,CAACC,GAAR,CAAa,GAAEJ,OAAQ,MAAvB,EAA8B,IAAAK,eAAA,EAAOJ,MAAP,CAA9B;EACD,CAHD,MAGO;IACL;IACAE,OAAO,CAACC,GAAR,CAAY,IAAAC,eAAA,EAAOJ,MAAP,CAAZ;EACD;AACF"}
1
+ {"version":3,"file":"debugShallow.js","names":["debugShallow","instance","message","output","shallowInternal","console","log","format"],"sources":["../../src/helpers/debugShallow.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ReactTestInstance } from 'react-test-renderer';\nimport { shallowInternal } from '../shallow';\nimport format from './format';\n\n/**\n * Log pretty-printed shallow test component instance\n */\nexport default function debugShallow(\n instance: ReactTestInstance | React.ReactElement<any>,\n message?: string\n) {\n const { output } = shallowInternal(instance);\n\n if (message) {\n // eslint-disable-next-line no-console\n console.log(`${message}\\n\\n`, format(output));\n } else {\n // eslint-disable-next-line no-console\n console.log(format(output));\n }\n}\n"],"mappings":";;;;;;AAEA;AACA;AAA8B;AAE9B;AACA;AACA;AACe,SAASA,YAAY,CAClCC,QAAqD,EACrDC,OAAgB,EAChB;EACA,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,wBAAe,EAACH,QAAQ,CAAC;EAE5C,IAAIC,OAAO,EAAE;IACX;IACAG,OAAO,CAACC,GAAG,CAAE,GAAEJ,OAAQ,MAAK,EAAE,IAAAK,eAAM,EAACJ,MAAM,CAAC,CAAC;EAC/C,CAAC,MAAM;IACL;IACAE,OAAO,CAACC,GAAG,CAAC,IAAAC,eAAM,EAACJ,MAAM,CAAC,CAAC;EAC7B;AACF"}
@@ -9,31 +9,21 @@ exports.prepareErrorMessage = exports.createQueryByError = exports.createLibrary
9
9
  exports.printDeprecationWarning = printDeprecationWarning;
10
10
  exports.throwRemovedFunctionError = throwRemovedFunctionError;
11
11
  exports.throwRenamedFunctionError = throwRenamedFunctionError;
12
-
13
12
  var _prettyFormat = _interopRequireDefault(require("pretty-format"));
14
-
15
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
-
17
14
  class ErrorWithStack extends Error {
18
15
  constructor(message, callsite) {
19
16
  super(message);
20
-
21
17
  if (Error.captureStackTrace) {
22
18
  Error.captureStackTrace(this, callsite);
23
19
  }
24
20
  }
25
-
26
21
  }
27
-
28
22
  exports.ErrorWithStack = ErrorWithStack;
29
-
30
23
  const createLibraryNotSupportedError = error => new Error(`Currently the only supported library to search by text is "react-native".\n\n${error instanceof Error ? error.message : ''}`);
31
-
32
24
  exports.createLibraryNotSupportedError = createLibraryNotSupportedError;
33
-
34
25
  const prepareErrorMessage = (error, name, value) => {
35
26
  let errorMessage;
36
-
37
27
  if (error instanceof Error) {
38
28
  // Strip info about custom predicate
39
29
  errorMessage = error.message.replace(/ matching custom predicate[^]*/gm, '');
@@ -42,59 +32,48 @@ const prepareErrorMessage = (error, name, value) => {
42
32
  } else {
43
33
  errorMessage = 'Caught unknown error';
44
34
  }
45
-
46
35
  if (name && value) {
47
36
  errorMessage += ` with ${name} ${(0, _prettyFormat.default)(value, {
48
37
  min: true
49
38
  })}`;
50
39
  }
51
-
52
40
  return errorMessage;
53
41
  };
54
-
55
42
  exports.prepareErrorMessage = prepareErrorMessage;
56
-
57
43
  const createQueryByError = (error, callsite) => {
58
44
  if (error instanceof Error) {
59
45
  if (error.message.includes('No instances found')) {
60
46
  return null;
61
47
  }
62
-
63
48
  throw new ErrorWithStack(error.message, callsite);
64
49
  }
65
-
66
- throw new ErrorWithStack( // generic refining of `unknown` is very hard, you cannot do `'toString' in error` or anything like that
50
+ throw new ErrorWithStack(
51
+ // generic refining of `unknown` is very hard, you cannot do `'toString' in error` or anything like that
67
52
  // Converting as any with extra safe optional chaining will do the job just as well
68
53
  `Query: caught unknown error type: ${typeof error}, value: ${error?.toString?.()}`, callsite);
69
54
  };
70
-
71
55
  exports.createQueryByError = createQueryByError;
72
-
73
56
  function copyStackTrace(target, stackTraceSource) {
74
57
  if (target instanceof Error && stackTraceSource.stack) {
75
58
  target.stack = stackTraceSource.stack.replace(stackTraceSource.message, target.message);
76
59
  }
77
60
  }
78
-
79
61
  const warned = {};
80
-
81
62
  function printDeprecationWarning(functionName) {
82
63
  if (warned[functionName]) {
83
64
  return;
84
- } // eslint-disable-next-line no-console
85
-
65
+ }
86
66
 
67
+ // eslint-disable-next-line no-console
87
68
  console.warn(`
88
69
  Deprecation Warning:
89
70
  Use of ${functionName} is not recommended and will be deleted in future versions of @testing-library/react-native.
90
71
  `);
91
72
  warned[functionName] = true;
92
73
  }
93
-
94
74
  function throwRemovedFunctionError(functionName, docsRef) {
95
75
  throw new Error(`"${functionName}" has been removed.\n\nPlease consult: https://callstack.github.io/react-native-testing-library/docs/${docsRef}`);
96
76
  }
97
-
98
77
  function throwRenamedFunctionError(functionName, newFunctionName) {
99
78
  throw new ErrorWithStack(`The "${functionName}" function has been renamed to "${newFunctionName}". Please replace all occurrences.`, throwRenamedFunctionError);
100
79
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":["ErrorWithStack","Error","constructor","message","callsite","captureStackTrace","createLibraryNotSupportedError","error","prepareErrorMessage","name","value","errorMessage","replace","toString","prettyFormat","min","createQueryByError","includes","copyStackTrace","target","stackTraceSource","stack","warned","printDeprecationWarning","functionName","console","warn","throwRemovedFunctionError","docsRef","throwRenamedFunctionError","newFunctionName"],"sources":["../../src/helpers/errors.ts"],"sourcesContent":["import prettyFormat from 'pretty-format';\n\nexport class ErrorWithStack extends Error {\n constructor(message: string | undefined, callsite: Function) {\n super(message);\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, callsite);\n }\n }\n}\n\nexport const createLibraryNotSupportedError = (error: unknown): Error =>\n new Error(\n `Currently the only supported library to search by text is \"react-native\".\\n\\n${\n error instanceof Error ? error.message : ''\n }`\n );\n\nexport const prepareErrorMessage = (\n // TS states that error caught in a catch close are of type `unknown`\n // most real cases will be `Error`, but better safe than sorry\n error: unknown,\n name?: string,\n value?: unknown\n): string => {\n let errorMessage: string;\n if (error instanceof Error) {\n // Strip info about custom predicate\n errorMessage = error.message.replace(\n / matching custom predicate[^]*/gm,\n ''\n );\n } else if (error && typeof error === 'object') {\n errorMessage = error.toString();\n } else {\n errorMessage = 'Caught unknown error';\n }\n\n if (name && value) {\n errorMessage += ` with ${name} ${prettyFormat(value, { min: true })}`;\n }\n return errorMessage;\n};\n\nexport const createQueryByError = (\n error: unknown,\n callsite: Function\n): null => {\n if (error instanceof Error) {\n if (error.message.includes('No instances found')) {\n return null;\n }\n throw new ErrorWithStack(error.message, callsite);\n }\n\n throw new ErrorWithStack(\n // generic refining of `unknown` is very hard, you cannot do `'toString' in error` or anything like that\n // Converting as any with extra safe optional chaining will do the job just as well\n `Query: caught unknown error type: ${typeof error}, value: ${(\n error as any\n )?.toString?.()}`,\n callsite\n );\n};\n\nexport function copyStackTrace(target: unknown, stackTraceSource: Error) {\n if (target instanceof Error && stackTraceSource.stack) {\n target.stack = stackTraceSource.stack.replace(\n stackTraceSource.message,\n target.message\n );\n }\n}\n\nconst warned: { [functionName: string]: boolean } = {};\n\nexport function printDeprecationWarning(functionName: string) {\n if (warned[functionName]) {\n return;\n }\n\n // eslint-disable-next-line no-console\n console.warn(`\n Deprecation Warning:\n Use of ${functionName} is not recommended and will be deleted in future versions of @testing-library/react-native.\n `);\n\n warned[functionName] = true;\n}\n\nexport function throwRemovedFunctionError(\n functionName: string,\n docsRef: string\n) {\n throw new Error(\n `\"${functionName}\" has been removed.\\n\\nPlease consult: https://callstack.github.io/react-native-testing-library/docs/${docsRef}`\n );\n}\n\nexport function throwRenamedFunctionError(\n functionName: string,\n newFunctionName: string\n) {\n throw new ErrorWithStack(\n `The \"${functionName}\" function has been renamed to \"${newFunctionName}\". Please replace all occurrences.`,\n throwRenamedFunctionError\n );\n}\n"],"mappings":";;;;;;;;;;;;AAAA;;;;AAEO,MAAMA,cAAN,SAA6BC,KAA7B,CAAmC;EACxCC,WAAW,CAACC,OAAD,EAA8BC,QAA9B,EAAkD;IAC3D,MAAMD,OAAN;;IACA,IAAIF,KAAK,CAACI,iBAAV,EAA6B;MAC3BJ,KAAK,CAACI,iBAAN,CAAwB,IAAxB,EAA8BD,QAA9B;IACD;EACF;;AANuC;;;;AASnC,MAAME,8BAA8B,GAAIC,KAAD,IAC5C,IAAIN,KAAJ,CACG,gFACCM,KAAK,YAAYN,KAAjB,GAAyBM,KAAK,CAACJ,OAA/B,GAAyC,EAC1C,EAHH,CADK;;;;AAOA,MAAMK,mBAAmB,GAAG,CAGjCD,KAHiC,EAIjCE,IAJiC,EAKjCC,KALiC,KAMtB;EACX,IAAIC,YAAJ;;EACA,IAAIJ,KAAK,YAAYN,KAArB,EAA4B;IAC1B;IACAU,YAAY,GAAGJ,KAAK,CAACJ,OAAN,CAAcS,OAAd,C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2D,CAK5D;;;EACAC,OAAO,CAACC,IAAR,CAAc;AAChB;AACA,WAAWF,YAAa;AACxB,GAHE;EAKAF,MAAM,CAACE,YAAD,CAAN,GAAuB,IAAvB;AACD;;AAEM,SAASG,yBAAT,CACLH,YADK,EAELI,OAFK,EAGL;EACA,MAAM,IAAI3B,KAAJ,CACH,IAAGuB,YAAa,wGAAuGI,OAAQ,EAD5H,CAAN;AAGD;;AAEM,SAASC,yBAAT,CACLL,YADK,EAELM,eAFK,EAGL;EACA,MAAM,IAAI9B,cAAJ,CACH,QAAOwB,YAAa,mCAAkCM,eAAgB,oCADnE,EAEJD,yBAFI,CAAN;AAID"}
1
+ {"version":3,"file":"errors.js","names":["ErrorWithStack","Error","constructor","message","callsite","captureStackTrace","createLibraryNotSupportedError","error","prepareErrorMessage","name","value","errorMessage","replace","toString","prettyFormat","min","createQueryByError","includes","copyStackTrace","target","stackTraceSource","stack","warned","printDeprecationWarning","functionName","console","warn","throwRemovedFunctionError","docsRef","throwRenamedFunctionError","newFunctionName"],"sources":["../../src/helpers/errors.ts"],"sourcesContent":["import prettyFormat from 'pretty-format';\n\nexport class ErrorWithStack extends Error {\n constructor(message: string | undefined, callsite: Function) {\n super(message);\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, callsite);\n }\n }\n}\n\nexport const createLibraryNotSupportedError = (error: unknown): Error =>\n new Error(\n `Currently the only supported library to search by text is \"react-native\".\\n\\n${\n error instanceof Error ? error.message : ''\n }`\n );\n\nexport const prepareErrorMessage = (\n // TS states that error caught in a catch close are of type `unknown`\n // most real cases will be `Error`, but better safe than sorry\n error: unknown,\n name?: string,\n value?: unknown\n): string => {\n let errorMessage: string;\n if (error instanceof Error) {\n // Strip info about custom predicate\n errorMessage = error.message.replace(\n / matching custom predicate[^]*/gm,\n ''\n );\n } else if (error && typeof error === 'object') {\n errorMessage = error.toString();\n } else {\n errorMessage = 'Caught unknown error';\n }\n\n if (name && value) {\n errorMessage += ` with ${name} ${prettyFormat(value, { min: true })}`;\n }\n return errorMessage;\n};\n\nexport const createQueryByError = (\n error: unknown,\n callsite: Function\n): null => {\n if (error instanceof Error) {\n if (error.message.includes('No instances found')) {\n return null;\n }\n throw new ErrorWithStack(error.message, callsite);\n }\n\n throw new ErrorWithStack(\n // generic refining of `unknown` is very hard, you cannot do `'toString' in error` or anything like that\n // Converting as any with extra safe optional chaining will do the job just as well\n `Query: caught unknown error type: ${typeof error}, value: ${(\n error as any\n )?.toString?.()}`,\n callsite\n );\n};\n\nexport function copyStackTrace(target: unknown, stackTraceSource: Error) {\n if (target instanceof Error && stackTraceSource.stack) {\n target.stack = stackTraceSource.stack.replace(\n stackTraceSource.message,\n target.message\n );\n }\n}\n\nconst warned: { [functionName: string]: boolean } = {};\n\nexport function printDeprecationWarning(functionName: string) {\n if (warned[functionName]) {\n return;\n }\n\n // eslint-disable-next-line no-console\n console.warn(`\n Deprecation Warning:\n Use of ${functionName} is not recommended and will be deleted in future versions of @testing-library/react-native.\n `);\n\n warned[functionName] = true;\n}\n\nexport function throwRemovedFunctionError(\n functionName: string,\n docsRef: string\n) {\n throw new Error(\n `\"${functionName}\" has been removed.\\n\\nPlease consult: https://callstack.github.io/react-native-testing-library/docs/${docsRef}`\n );\n}\n\nexport function throwRenamedFunctionError(\n functionName: string,\n newFunctionName: string\n) {\n throw new ErrorWithStack(\n `The \"${functionName}\" function has been renamed to \"${newFunctionName}\". Please replace all occurrences.`,\n throwRenamedFunctionError\n );\n}\n"],"mappings":";;;;;;;;;;;AAAA;AAAyC;AAElC,MAAMA,cAAc,SAASC,KAAK,CAAC;EACxCC,WAAW,CAACC,OAA2B,EAAEC,QAAkB,EAAE;IAC3D,KAAK,CAACD,OAAO,CAAC;IACd,IAAIF,KAAK,CAACI,iBAAiB,EAAE;MAC3BJ,KAAK,CAACI,iBAAiB,CAAC,IAAI,EAAED,QAAQ,CAAC;IACzC;EACF;AACF;AAAC;AAEM,MAAME,8BAA8B,GAAIC,KAAc,IAC3D,IAAIN,KAAK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,gBAAgB,CAACC,KAAK,CAACT,OAAO,CAC3CQ,gBAAgB,CAACjB,OAAO,EACxBgB,MAAM,CAAChB,OAAO,CACf;EACH;AACF;AAEA,MAAMmB,MAA2C,GAAG,CAAC,CAAC;AAE/C,SAASC,uBAAuB,CAACC,YAAoB,EAAE;EAC5D,IAAIF,MAAM,CAACE,YAAY,CAAC,EAAE;IACxB;EACF;;EAEA;EACAC,OAAO,CAACC,IAAI,CAAE;AAChB;AACA,WAAWF,YAAa;AACxB,GAAG,CAAC;EAEFF,MAAM,CAACE,YAAY,CAAC,GAAG,IAAI;AAC7B;AAEO,SAASG,yBAAyB,CACvCH,YAAoB,EACpBI,OAAe,EACf;EACA,MAAM,IAAI3B,KAAK,CACZ,IAAGuB,YAAa,wGAAuGI,OAAQ,EAAC,CAClI;AACH;AAEO,SAASC,yBAAyB,CACvCL,YAAoB,EACpBM,eAAuB,EACvB;EACA,MAAM,IAAI9B,cAAc,CACrB,QAAOwB,YAAa,mCAAkCM,eAAgB,oCAAmC,EAC1GD,yBAAyB,CAC1B;AACH"}
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.filterNodeByType = void 0;
7
-
8
7
  const filterNodeByType = (node, type) => node.type === type;
9
-
10
8
  exports.filterNodeByType = filterNodeByType;
11
9
  //# sourceMappingURL=filterNodeByType.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"filterNodeByType.js","names":["filterNodeByType","node","type"],"sources":["../../src/helpers/filterNodeByType.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport * as React from 'react';\n\nexport const filterNodeByType = (\n node: ReactTestInstance | React.ReactElement,\n type: React.ElementType | string\n) => node.type === type;\n"],"mappings":";;;;;;;AAGO,MAAMA,gBAAgB,GAAG,CAC9BC,IAD8B,EAE9BC,IAF8B,KAG3BD,IAAI,CAACC,IAAL,KAAcA,IAHZ"}
1
+ {"version":3,"file":"filterNodeByType.js","names":["filterNodeByType","node","type"],"sources":["../../src/helpers/filterNodeByType.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport * as React from 'react';\n\nexport const filterNodeByType = (\n node: ReactTestInstance | React.ReactElement,\n type: React.ElementType | string\n) => node.type === type;\n"],"mappings":";;;;;;AAGO,MAAMA,gBAAgB,GAAG,CAC9BC,IAA4C,EAC5CC,IAAgC,KAC7BD,IAAI,CAACC,IAAI,KAAKA,IAAI;AAAC"}
@@ -0,0 +1,10 @@
1
+ import { ReactTestInstance } from 'react-test-renderer';
2
+ interface FindAllOptions {
3
+ /** Match elements hidden from accessibility */
4
+ includeHiddenElements?: boolean;
5
+ /** RTL-compatible alias to `includeHiddenElements` */
6
+ hidden?: boolean;
7
+ matchDeepestOnly?: boolean;
8
+ }
9
+ export declare function findAll(root: ReactTestInstance, predicate: (element: ReactTestInstance) => boolean, options?: FindAllOptions): ReactTestInstance[];
10
+ export {};
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findAll = findAll;
7
+ var _config = require("../config");
8
+ var _accessiblity = require("./accessiblity");
9
+ function findAll(root, predicate, options) {
10
+ const results = findAllInternal(root, predicate, options);
11
+ const includeHiddenElements = options?.includeHiddenElements ?? options?.hidden ?? (0, _config.getConfig)()?.defaultIncludeHiddenElements;
12
+ if (includeHiddenElements) {
13
+ return results;
14
+ }
15
+ const cache = new WeakMap();
16
+ return results.filter(element => !(0, _accessiblity.isHiddenFromAccessibility)(element, {
17
+ cache
18
+ }));
19
+ }
20
+
21
+ // Extracted from React Test Renderer
22
+ // src: https://github.com/facebook/react/blob/8e2bde6f2751aa6335f3cef488c05c3ea08e074a/packages/react-test-renderer/src/ReactTestRenderer.js#L402
23
+ function findAllInternal(root, predicate, options) {
24
+ const results = [];
25
+
26
+ // Match descendants first but do not add them to results yet.
27
+ const matchingDescendants = [];
28
+ root.children.forEach(child => {
29
+ if (typeof child === 'string') {
30
+ return;
31
+ }
32
+ matchingDescendants.push(...findAllInternal(child, predicate, options));
33
+ });
34
+ if (
35
+ // When matchDeepestOnly = true: add current element only if no descendants match
36
+ (!options?.matchDeepestOnly || matchingDescendants.length === 0) && predicate(root)) {
37
+ results.push(root);
38
+ }
39
+
40
+ // Add matching descendants after element to preserve original tree walk order.
41
+ results.push(...matchingDescendants);
42
+ return results;
43
+ }
44
+ //# sourceMappingURL=findAll.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findAll.js","names":["findAll","root","predicate","options","results","findAllInternal","includeHiddenElements","hidden","getConfig","defaultIncludeHiddenElements","cache","WeakMap","filter","element","isHiddenFromAccessibility","matchingDescendants","children","forEach","child","push","matchDeepestOnly","length"],"sources":["../../src/helpers/findAll.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { getConfig } from '../config';\nimport { isHiddenFromAccessibility } from './accessiblity';\n\ninterface FindAllOptions {\n /** Match elements hidden from accessibility */\n includeHiddenElements?: boolean;\n\n /** RTL-compatible alias to `includeHiddenElements` */\n hidden?: boolean;\n\n /* Exclude any ancestors of deepest matched elements even if they match the predicate */\n matchDeepestOnly?: boolean;\n}\n\nexport function findAll(\n root: ReactTestInstance,\n predicate: (element: ReactTestInstance) => boolean,\n options?: FindAllOptions\n) {\n const results = findAllInternal(root, predicate, options);\n\n const includeHiddenElements =\n options?.includeHiddenElements ??\n options?.hidden ??\n getConfig()?.defaultIncludeHiddenElements;\n\n if (includeHiddenElements) {\n return results;\n }\n\n const cache = new WeakMap<ReactTestInstance>();\n return results.filter(\n (element) => !isHiddenFromAccessibility(element, { cache })\n );\n}\n\n// Extracted from React Test Renderer\n// src: https://github.com/facebook/react/blob/8e2bde6f2751aa6335f3cef488c05c3ea08e074a/packages/react-test-renderer/src/ReactTestRenderer.js#L402\nfunction findAllInternal(\n root: ReactTestInstance,\n predicate: (element: ReactTestInstance) => boolean,\n options?: FindAllOptions\n): Array<ReactTestInstance> {\n const results: ReactTestInstance[] = [];\n\n // Match descendants first but do not add them to results yet.\n const matchingDescendants: ReactTestInstance[] = [];\n root.children.forEach((child) => {\n if (typeof child === 'string') {\n return;\n }\n matchingDescendants.push(...findAllInternal(child, predicate, options));\n });\n\n if (\n // When matchDeepestOnly = true: add current element only if no descendants match\n (!options?.matchDeepestOnly || matchingDescendants.length === 0) &&\n predicate(root)\n ) {\n results.push(root);\n }\n\n // Add matching descendants after element to preserve original tree walk order.\n results.push(...matchingDescendants);\n\n return results;\n}\n"],"mappings":";;;;;;AACA;AACA;AAaO,SAASA,OAAO,CACrBC,IAAuB,EACvBC,SAAkD,EAClDC,OAAwB,EACxB;EACA,MAAMC,OAAO,GAAGC,eAAe,CAACJ,IAAI,EAAEC,SAAS,EAAEC,OAAO,CAAC;EAEzD,MAAMG,qBAAqB,GACzBH,OAAO,EAAEG,qBAAqB,IAC9BH,OAAO,EAAEI,MAAM,IACf,IAAAC,iBAAS,GAAE,EAAEC,4BAA4B;EAE3C,IAAIH,qBAAqB,EAAE;IACzB,OAAOF,OAAO;EAChB;EAEA,MAAMM,KAAK,GAAG,IAAIC,OAAO,EAAqB;EAC9C,OAAOP,OAAO,CAACQ,MAAM,CAClBC,OAAO,IAAK,CAAC,IAAAC,uCAAyB,EAACD,OAAO,EAAE;IAAEH;EAAM,CAAC,CAAC,CAC5D;AACH;;AAEA;AACA;AACA,SAASL,eAAe,CACtBJ,IAAuB,EACvBC,SAAkD,EAClDC,OAAwB,EACE;EAC1B,MAAMC,OAA4B,GAAG,EAAE;;EAEvC;EACA,MAAMW,mBAAwC,GAAG,EAAE;EACnDd,IAAI,CAACe,QAAQ,CAACC,OAAO,CAAEC,KAAK,IAAK;IAC/B,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC7B;IACF;IACAH,mBAAmB,CAACI,IAAI,CAAC,GAAGd,eAAe,CAACa,KAAK,EAAEhB,SAAS,EAAEC,OAAO,CAAC,CAAC;EACzE,CAAC,CAAC;EAEF;EACE;EACA,CAAC,CAACA,OAAO,EAAEiB,gBAAgB,IAAIL,mBAAmB,CAACM,MAAM,KAAK,CAAC,KAC/DnB,SAAS,CAACD,IAAI,CAAC,EACf;IACAG,OAAO,CAACe,IAAI,CAAClB,IAAI,CAAC;EACpB;;EAEA;EACAG,OAAO,CAACe,IAAI,CAAC,GAAGJ,mBAAmB,CAAC;EAEpC,OAAOX,OAAO;AAChB"}
@@ -1,3 +1,7 @@
1
1
  import type { ReactTestRendererJSON } from 'react-test-renderer';
2
- declare const format: (input: ReactTestRendererJSON | ReactTestRendererJSON[]) => string;
2
+ type MapPropsFunction = (props: Record<string, unknown>, node: ReactTestRendererJSON) => Record<string, unknown>;
3
+ export type FormatOptions = {
4
+ mapProps?: MapPropsFunction;
5
+ };
6
+ declare const format: (input: ReactTestRendererJSON | ReactTestRendererJSON[], options?: FormatOptions) => string;
3
7
  export default format;
@@ -4,18 +4,28 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _prettyFormat = _interopRequireWildcard(require("pretty-format"));
9
-
10
8
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
-
12
9
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
-
14
- const format = input => (0, _prettyFormat.default)(input, {
15
- plugins: [_prettyFormat.plugins.ReactTestComponent, _prettyFormat.plugins.ReactElement],
10
+ const format = (input, options = {}) => (0, _prettyFormat.default)(input, {
11
+ plugins: [getCustomPlugin(options.mapProps), _prettyFormat.plugins.ReactElement],
16
12
  highlight: true
17
13
  });
18
-
14
+ const getCustomPlugin = mapProps => {
15
+ return {
16
+ test: val => _prettyFormat.plugins.ReactTestComponent.test(val),
17
+ serialize: (val, config, indentation, depth, refs, printer) => {
18
+ let newVal = val;
19
+ if (mapProps && val.props) {
20
+ newVal = {
21
+ ...val,
22
+ props: mapProps(val.props, val)
23
+ };
24
+ }
25
+ return _prettyFormat.plugins.ReactTestComponent.serialize(newVal, config, indentation, depth, refs, printer);
26
+ }
27
+ };
28
+ };
19
29
  var _default = format;
20
30
  exports.default = _default;
21
31
  //# sourceMappingURL=format.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","names":["format","input","prettyFormat","plugins","ReactTestComponent","ReactElement","highlight"],"sources":["../../src/helpers/format.ts"],"sourcesContent":["import type { ReactTestRendererJSON } from 'react-test-renderer';\nimport prettyFormat, { plugins } from 'pretty-format';\n\nconst format = (input: ReactTestRendererJSON | ReactTestRendererJSON[]) =>\n prettyFormat(input, {\n plugins: [plugins.ReactTestComponent, plugins.ReactElement],\n highlight: true,\n });\n\nexport default format;\n"],"mappings":";;;;;;;AACA;;;;;;AAEA,MAAMA,MAAM,GAAIC,KAAD,IACb,IAAAC,qBAAA,EAAaD,KAAb,EAAoB;EAClBE,OAAO,EAAE,CAACA,qBAAA,CAAQC,kBAAT,EAA6BD,qBAAA,CAAQE,YAArC,CADS;EAElBC,SAAS,EAAE;AAFO,CAApB,CADF;;eAMeN,M"}
1
+ {"version":3,"file":"format.js","names":["format","input","options","prettyFormat","plugins","getCustomPlugin","mapProps","ReactElement","highlight","test","val","ReactTestComponent","serialize","config","indentation","depth","refs","printer","newVal","props"],"sources":["../../src/helpers/format.ts"],"sourcesContent":["import type { ReactTestRendererJSON } from 'react-test-renderer';\nimport prettyFormat, { NewPlugin, plugins } from 'pretty-format';\n\ntype MapPropsFunction = (\n props: Record<string, unknown>,\n node: ReactTestRendererJSON\n) => Record<string, unknown>;\n\nexport type FormatOptions = {\n mapProps?: MapPropsFunction;\n};\n\nconst format = (\n input: ReactTestRendererJSON | ReactTestRendererJSON[],\n options: FormatOptions = {}\n) =>\n prettyFormat(input, {\n plugins: [getCustomPlugin(options.mapProps), plugins.ReactElement],\n highlight: true,\n });\n\nconst getCustomPlugin = (mapProps?: MapPropsFunction): NewPlugin => {\n return {\n test: (val) => plugins.ReactTestComponent.test(val),\n serialize: (val, config, indentation, depth, refs, printer) => {\n let newVal = val;\n if (mapProps && val.props) {\n newVal = { ...val, props: mapProps(val.props, val) };\n }\n return plugins.ReactTestComponent.serialize(\n newVal,\n config,\n indentation,\n depth,\n refs,\n printer\n );\n },\n };\n};\n\nexport default format;\n"],"mappings":";;;;;;AACA;AAAiE;AAAA;AAWjE,MAAMA,MAAM,GAAG,CACbC,KAAsD,EACtDC,OAAsB,GAAG,CAAC,CAAC,KAE3B,IAAAC,qBAAY,EAACF,KAAK,EAAE;EAClBG,OAAO,EAAE,CAACC,eAAe,CAACH,OAAO,CAACI,QAAQ,CAAC,EAAEF,qBAAO,CAACG,YAAY,CAAC;EAClEC,SAAS,EAAE;AACb,CAAC,CAAC;AAEJ,MAAMH,eAAe,GAAIC,QAA2B,IAAgB;EAClE,OAAO;IACLG,IAAI,EAAGC,GAAG,IAAKN,qBAAO,CAACO,kBAAkB,CAACF,IAAI,CAACC,GAAG,CAAC;IACnDE,SAAS,EAAE,CAACF,GAAG,EAAEG,MAAM,EAAEC,WAAW,EAAEC,KAAK,EAAEC,IAAI,EAAEC,OAAO,KAAK;MAC7D,IAAIC,MAAM,GAAGR,GAAG;MAChB,IAAIJ,QAAQ,IAAII,GAAG,CAACS,KAAK,EAAE;QACzBD,MAAM,GAAG;UAAE,GAAGR,GAAG;UAAES,KAAK,EAAEb,QAAQ,CAACI,GAAG,CAACS,KAAK,EAAET,GAAG;QAAE,CAAC;MACtD;MACA,OAAON,qBAAO,CAACO,kBAAkB,CAACC,SAAS,CACzCM,MAAM,EACNL,MAAM,EACNC,WAAW,EACXC,KAAK,EACLC,IAAI,EACJC,OAAO,CACR;IACH;EACF,CAAC;AACH,CAAC;AAAC,eAEajB,MAAM;AAAA"}
@@ -0,0 +1,2 @@
1
+ import type { ReactTestInstance } from 'react-test-renderer';
2
+ export declare function getTextContent(element: ReactTestInstance | string | null): string;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getTextContent = getTextContent;
7
+ function getTextContent(element) {
8
+ if (!element) {
9
+ return '';
10
+ }
11
+ if (typeof element === 'string') {
12
+ return element;
13
+ }
14
+ const result = [];
15
+ element.children?.forEach(child => {
16
+ result.push(getTextContent(child));
17
+ });
18
+ return result.join('');
19
+ }
20
+ //# sourceMappingURL=getTextContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTextContent.js","names":["getTextContent","element","result","children","forEach","child","push","join"],"sources":["../../src/helpers/getTextContent.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\n\nexport function getTextContent(\n element: ReactTestInstance | string | null\n): string {\n if (!element) {\n return '';\n }\n\n if (typeof element === 'string') {\n return element;\n }\n\n const result: string[] = [];\n element.children?.forEach((child) => {\n result.push(getTextContent(child));\n });\n\n return result.join('');\n}\n"],"mappings":";;;;;;AAEO,SAASA,cAAc,CAC5BC,OAA0C,EAClC;EACR,IAAI,CAACA,OAAO,EAAE;IACZ,OAAO,EAAE;EACX;EAEA,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;IAC/B,OAAOA,OAAO;EAChB;EAEA,MAAMC,MAAgB,GAAG,EAAE;EAC3BD,OAAO,CAACE,QAAQ,EAAEC,OAAO,CAAEC,KAAK,IAAK;IACnCH,MAAM,CAACI,IAAI,CAACN,cAAc,CAACK,KAAK,CAAC,CAAC;EACpC,CAAC,CAAC;EAEF,OAAOH,MAAM,CAACK,IAAI,CAAC,EAAE,CAAC;AACxB"}
@@ -0,0 +1,3 @@
1
+ import { AccessibilityState } from 'react-native';
2
+ import { ReactTestInstance } from 'react-test-renderer';
3
+ export declare function matchAccessibilityState(node: ReactTestInstance, matcher: AccessibilityState): boolean;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.matchAccessibilityState = matchAccessibilityState;
7
+ var _accessiblity = require("../accessiblity");
8
+ /**
9
+ * Default accessibility state values based on experiments using accessibility
10
+ * inspector/screen reader on iOS and Android.
11
+ *
12
+ * @see https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State
13
+ */
14
+ const defaultState = {
15
+ disabled: false,
16
+ selected: false,
17
+ checked: undefined,
18
+ busy: false,
19
+ expanded: undefined
20
+ };
21
+ function matchAccessibilityState(node, matcher) {
22
+ const state = node.props.accessibilityState;
23
+ return _accessiblity.accessibilityStateKeys.every(key => matchState(state, matcher, key));
24
+ }
25
+ function matchState(state, matcher, key) {
26
+ return matcher[key] === undefined || matcher[key] === (state?.[key] ?? defaultState[key]);
27
+ }
28
+ //# sourceMappingURL=accessibilityState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessibilityState.js","names":["defaultState","disabled","selected","checked","undefined","busy","expanded","matchAccessibilityState","node","matcher","state","props","accessibilityState","accessibilityStateKeys","every","key","matchState"],"sources":["../../../src/helpers/matchers/accessibilityState.ts"],"sourcesContent":["import { AccessibilityState } from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { accessibilityStateKeys } from '../accessiblity';\n\n/**\n * Default accessibility state values based on experiments using accessibility\n * inspector/screen reader on iOS and Android.\n *\n * @see https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State\n */\nconst defaultState: AccessibilityState = {\n disabled: false,\n selected: false,\n checked: undefined,\n busy: false,\n expanded: undefined,\n};\n\nexport function matchAccessibilityState(\n node: ReactTestInstance,\n matcher: AccessibilityState\n) {\n const state = node.props.accessibilityState;\n return accessibilityStateKeys.every((key) => matchState(state, matcher, key));\n}\n\nfunction matchState(\n state: AccessibilityState,\n matcher: AccessibilityState,\n key: keyof AccessibilityState\n) {\n return (\n matcher[key] === undefined ||\n matcher[key] === (state?.[key] ?? defaultState[key])\n );\n}\n"],"mappings":";;;;;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,YAAgC,GAAG;EACvCC,QAAQ,EAAE,KAAK;EACfC,QAAQ,EAAE,KAAK;EACfC,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,KAAK;EACXC,QAAQ,EAAEF;AACZ,CAAC;AAEM,SAASG,uBAAuB,CACrCC,IAAuB,EACvBC,OAA2B,EAC3B;EACA,MAAMC,KAAK,GAAGF,IAAI,CAACG,KAAK,CAACC,kBAAkB;EAC3C,OAAOC,oCAAsB,CAACC,KAAK,CAAEC,GAAG,IAAKC,UAAU,CAACN,KAAK,EAAED,OAAO,EAAEM,GAAG,CAAC,CAAC;AAC/E;AAEA,SAASC,UAAU,CACjBN,KAAyB,EACzBD,OAA2B,EAC3BM,GAA6B,EAC7B;EACA,OACEN,OAAO,CAACM,GAAG,CAAC,KAAKX,SAAS,IAC1BK,OAAO,CAACM,GAAG,CAAC,MAAML,KAAK,GAAGK,GAAG,CAAC,IAAIf,YAAY,CAACe,GAAG,CAAC,CAAC;AAExD"}
@@ -0,0 +1,9 @@
1
+ import { ReactTestInstance } from 'react-test-renderer';
2
+ import { TextMatch } from '../../matches';
3
+ export interface AccessibilityValueMatcher {
4
+ min?: number;
5
+ max?: number;
6
+ now?: number;
7
+ text?: TextMatch;
8
+ }
9
+ export declare function matchAccessibilityValue(node: ReactTestInstance, matcher: AccessibilityValueMatcher): boolean;