@testing-library/react-native 12.4.2 → 12.4.3

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.
@@ -5,25 +5,257 @@ import { TextMatch, TextMatchOptions } from '../matches';
5
5
  import { Style } from './to-have-style';
6
6
  export interface JestNativeMatchers<R> {
7
7
  /**
8
- * Assert whether an element is present in the element tree or not.
8
+ * Assert whether a host element is present in the element tree (screen) or not.
9
+ *
10
+ * @see
11
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeonthescreen)
12
+ *
13
+ * @example
14
+ * <Text>Hello</Text>
15
+ *
16
+ * expect(getByText('Hello')).toBeOnTheScreen()
17
+ * expect(queryByText('Other')).not.toBeOnTheScreen()
9
18
  */
10
19
  toBeOnTheScreen(): R;
20
+ /**
21
+ * Assert whether a host element is checked based on accessibility props.
22
+ *
23
+ * @see
24
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobechecked)
25
+ *
26
+ * @see {@link toBePartiallyChecked} for a related matcher.
27
+ *
28
+ * @example
29
+ * <View accessible role="checkbox" aria-checked aria-label="Enable" />
30
+ *
31
+ * expect(getByRole('checkbox', { name: "Enable" })).toBeChecked()
32
+ */
11
33
  toBeChecked(): R;
34
+ /**
35
+ * Assert whether a host element is collapsed based on accessibility props.
36
+ *
37
+ * @see
38
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeexpanded)
39
+ *
40
+ * @see {@link toBeExpanded} for an inverse matcher.
41
+ *
42
+ * @example
43
+ * <View testID="details" aria-expanded={false} />
44
+ *
45
+ * expect(getByTestId('details').toBeCollapsed()
46
+ */
12
47
  toBeCollapsed(): R;
48
+ /**
49
+ * Assert whether a host element is disabled based on accessibility props.
50
+ *
51
+ * This matcher will check ancestor elements for their disabled state as well.
52
+ *
53
+ * @see
54
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeenabled)
55
+ *
56
+ * @see {@link toBeEnabled} for an inverse matcher.
57
+ *
58
+ * @example
59
+ * <View role="button" aria-disabled />
60
+ *
61
+ * expect(getByRole('button').toBeDisabled()
62
+ *
63
+ */
13
64
  toBeDisabled(): R;
65
+ /**
66
+ * Assert whether a host element is busy based on accessibility props.
67
+ *
68
+ * This matcher will check ancestor elements for their disabled state as well.
69
+ *
70
+ * @see
71
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobebusy)
72
+ *
73
+ * @example
74
+ * <View testID="loader" aria-busy />
75
+ *
76
+ * expect(getByTestId('loader')).toBeBusy()
77
+ */
14
78
  toBeBusy(): R;
79
+ /**
80
+ * Assert whether a host element has no host children or text content.
81
+ *
82
+ * @see
83
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeemptyelement)
84
+ *
85
+ * @example
86
+ * <View testID="not-empty">
87
+ * <View testID="empty" />
88
+ * </View>
89
+ *
90
+ * expect(getByTestId('empty')).toBeEmptyElement()
91
+ * expect(getByTestId('not-mepty')).not.toBeEmptyElement()
92
+ */
15
93
  toBeEmptyElement(): R;
94
+ /**
95
+ * Assert whether a host element is enabled based on accessibility props.
96
+ *
97
+ * This matcher will check ancestor elements for their disabled state as well.
98
+ *
99
+ * @see
100
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeenabled)
101
+ *
102
+ * @see {@link toBeDisabled} for inverse matcher.
103
+ *
104
+ * @example
105
+ * <View role="button" aria-disabled={false} />
106
+ *
107
+ * expect(getByRole('button').toBeEnabled()
108
+ */
16
109
  toBeEnabled(): R;
110
+ /**
111
+ * Assert whether a host element is expanded based on accessibility props.
112
+ *
113
+ * @see
114
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeexpanded)
115
+ *
116
+ * @see {@link toBeCollapsed} for inverse matcher.
117
+ *
118
+ * @example
119
+ * <View testID="details" aria-expanded />
120
+ *
121
+ * expect(getByTestId('details').toBeExpanded()
122
+ */
17
123
  toBeExpanded(): R;
124
+ /**
125
+ * Assert whether a host element is partially checked based on accessibility props.
126
+ *
127
+ * @see
128
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobechecked)
129
+ *
130
+ * @see {@link toBeChecked} for related matcher.
131
+ *
132
+ * @example
133
+ * <View accessible role="checkbox" aria-checked="mixed" aria-label="Enable" />
134
+ *
135
+ * expect(getByRole('checkbox', { name: "Enable" })).toBePartiallyChecked()
136
+ */
18
137
  toBePartiallyChecked(): R;
138
+ /**
139
+ * Assert whether a host element is selected based on accessibility props.
140
+ *
141
+ * @see
142
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeselected)
143
+ *
144
+ * @example
145
+ * <View testID="view" aria-selected />
146
+ *
147
+ * expect(getByTestId('view')).toBeSelected()
148
+ */
19
149
  toBeSelected(): R;
150
+ /**
151
+ * Assert whether a host element is visible based on style and accessibility props.
152
+ *
153
+ * This matcher will check ancestor elements for their visibility as well.
154
+ *
155
+ * @see
156
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobevisible)
157
+ *
158
+ * @example
159
+ * <View testID="visible" />
160
+ * <View testID="not-visible" style={{ display: 'none' }} />
161
+ *
162
+ * expect(getByTestId('visible')).toBeVisible()
163
+ * expect(getByTestId('not-visible')).not.toBeVisible()
164
+ */
20
165
  toBeVisible(): R;
166
+ /**
167
+ * Assert whether a host element contains another host element.
168
+ *
169
+ * @see
170
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tocontainelement)
171
+ *
172
+ * @example
173
+ * <View testID="outer">
174
+ * <View testID="inner" />
175
+ * </View>
176
+ *
177
+ * expect(getByTestId('outer')).toContainElement(getByTestId('inner'));
178
+ */
21
179
  toContainElement(element: ReactTestInstance | null): R;
180
+ /**
181
+ * Assert whether a host element has a given accessbility value.
182
+ *
183
+ * @see
184
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveaccessibilityvalue)
185
+ *
186
+ *
187
+ * @example
188
+ * <View testID="view" aria-valuetext="33%" />
189
+ *
190
+ * expect(getByTestId('view')).toHaveAccessibilityValue({ text: '33%' });
191
+ */
22
192
  toHaveAccessibilityValue(expectedValue: AccessibilityValueMatcher): R;
193
+ /**
194
+ * Assert whether a host element has a given accessibile name based on the accessibility label or text content.
195
+ *
196
+ * @see
197
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveaccessiblename)
198
+ *
199
+ * @example
200
+ * <View testID="view" aria-label="Hello" />
201
+ *
202
+ * expect(getByTestId('view')).toHaveAccessibleName('Hello');
203
+ */
23
204
  toHaveAccessibleName(expectedName?: TextMatch, options?: TextMatchOptions): R;
205
+ /**
206
+ * Assert whether a host `TextInput` element has a given display value based on `value` and `defaultValue` props.
207
+ *
208
+ * @see
209
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavedisplayvalue)
210
+ *
211
+ * @example
212
+ * <TextInput testID="input" value="Hello" />
213
+ *
214
+ * expect(getByTestId('input')).toHaveDisplayValue('Hello');
215
+ */
24
216
  toHaveDisplayValue(expectedValue: TextMatch, options?: TextMatchOptions): R;
217
+ /**
218
+ * Assert whether a host element has a given prop.
219
+ *
220
+ * @see
221
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveprop)
222
+ *
223
+ * @example
224
+ * <Text testID="text" numberOfLines={1]} />
225
+ *
226
+ * expect(getByTestId('text')).toHaveProp('numberOfLines');
227
+ * expect(getByTestId('text')).toHaveProp('numberOfLines', 1);
228
+ */
25
229
  toHaveProp(name: string, expectedValue?: unknown): R;
230
+ /**
231
+ * Assert whether a host element has a given style.
232
+ *
233
+ * @see
234
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavestyle)
235
+ *
236
+ * @example
237
+ * <View testID="view" style={{ width: '100%' }} />
238
+ *
239
+ * expect(getByTestId('view')).toHaveStyle({ width: '100%' });
240
+ * expect(getByTestId('view')).not.toHaveStyle({ width: '50%' });
241
+ */
26
242
  toHaveStyle(style: StyleProp<Style>): R;
243
+ /**
244
+ * Assert whether a host element has a given text content.
245
+ *
246
+ * @see
247
+ * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavetextcontent)
248
+ *
249
+ * @example
250
+ * <View testID="view">
251
+ * <Text>Hello World</Text>
252
+ * </View>
253
+ *
254
+ * expect(getByTestId('view')).toHaveTextContent('Hello World');
255
+ * expect(getByTestId('view')).toHaveTextContent('Hello', { exact: false }});
256
+ * expect(getByTestId('view')).toHaveTextContent(/hello/i);
257
+ * expect(getByTestId('view')).not.toHaveTextContent('Hello');
258
+ */
27
259
  toHaveTextContent(expectedText: TextMatch, options?: TextMatchOptions): R;
28
260
  }
29
261
  declare global {
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/matchers/types.ts"],"sourcesContent":["import type { StyleProp } from 'react-native';\nimport type { ReactTestInstance } from 'react-test-renderer';\nimport { AccessibilityValueMatcher } from '../helpers/matchers/match-accessibility-value';\nimport { TextMatch, TextMatchOptions } from '../matches';\nimport { Style } from './to-have-style';\n\nexport interface JestNativeMatchers<R> {\n /**\n * Assert whether an element is present in the element tree or not.\n */\n toBeOnTheScreen(): R;\n\n toBeChecked(): R;\n toBeCollapsed(): R;\n toBeDisabled(): R;\n toBeBusy(): R;\n toBeEmptyElement(): R;\n toBeEnabled(): R;\n toBeExpanded(): R;\n toBePartiallyChecked(): R;\n toBeSelected(): R;\n toBeVisible(): R;\n toContainElement(element: ReactTestInstance | null): R;\n toHaveAccessibilityValue(expectedValue: AccessibilityValueMatcher): R;\n toHaveAccessibleName(expectedName?: TextMatch, options?: TextMatchOptions): R;\n toHaveDisplayValue(expectedValue: TextMatch, options?: TextMatchOptions): R;\n toHaveProp(name: string, expectedValue?: unknown): R;\n toHaveStyle(style: StyleProp<Style>): R;\n toHaveTextContent(expectedText: TextMatch, options?: TextMatchOptions): R;\n}\n\n// Implicit Jest global `expect`.\ndeclare global {\n namespace jest {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface Matchers<R, T = {}> extends JestNativeMatchers<R> {}\n }\n}\n\n// Explicit `@jest/globals` `expect` matchers.\n// @ts-ignore\ndeclare module '@jest/expect' {\n interface Matchers<R extends void | Promise<void>>\n extends JestNativeMatchers<R> {}\n}\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/matchers/types.ts"],"sourcesContent":["import type { StyleProp } from 'react-native';\nimport type { ReactTestInstance } from 'react-test-renderer';\nimport { AccessibilityValueMatcher } from '../helpers/matchers/match-accessibility-value';\nimport { TextMatch, TextMatchOptions } from '../matches';\nimport { Style } from './to-have-style';\n\nexport interface JestNativeMatchers<R> {\n /**\n * Assert whether a host element is present in the element tree (screen) or not.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeonthescreen)\n *\n * @example\n * <Text>Hello</Text>\n *\n * expect(getByText('Hello')).toBeOnTheScreen()\n * expect(queryByText('Other')).not.toBeOnTheScreen()\n */\n toBeOnTheScreen(): R;\n\n /**\n * Assert whether a host element is checked based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobechecked)\n *\n * @see {@link toBePartiallyChecked} for a related matcher.\n *\n * @example\n * <View accessible role=\"checkbox\" aria-checked aria-label=\"Enable\" />\n *\n * expect(getByRole('checkbox', { name: \"Enable\" })).toBeChecked()\n */\n toBeChecked(): R;\n\n /**\n * Assert whether a host element is collapsed based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeexpanded)\n *\n * @see {@link toBeExpanded} for an inverse matcher.\n *\n * @example\n * <View testID=\"details\" aria-expanded={false} />\n *\n * expect(getByTestId('details').toBeCollapsed()\n */\n toBeCollapsed(): R;\n\n /**\n * Assert whether a host element is disabled based on accessibility props.\n *\n * This matcher will check ancestor elements for their disabled state as well.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeenabled)\n *\n * @see {@link toBeEnabled} for an inverse matcher.\n *\n * @example\n * <View role=\"button\" aria-disabled />\n *\n * expect(getByRole('button').toBeDisabled()\n *\n */\n toBeDisabled(): R;\n\n /**\n * Assert whether a host element is busy based on accessibility props.\n *\n * This matcher will check ancestor elements for their disabled state as well.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobebusy)\n *\n * @example\n * <View testID=\"loader\" aria-busy />\n *\n * expect(getByTestId('loader')).toBeBusy()\n */\n toBeBusy(): R;\n\n /**\n * Assert whether a host element has no host children or text content.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeemptyelement)\n *\n * @example\n * <View testID=\"not-empty\">\n * <View testID=\"empty\" />\n * </View>\n *\n * expect(getByTestId('empty')).toBeEmptyElement()\n * expect(getByTestId('not-mepty')).not.toBeEmptyElement()\n */\n toBeEmptyElement(): R;\n\n /**\n * Assert whether a host element is enabled based on accessibility props.\n *\n * This matcher will check ancestor elements for their disabled state as well.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeenabled)\n *\n * @see {@link toBeDisabled} for inverse matcher.\n *\n * @example\n * <View role=\"button\" aria-disabled={false} />\n *\n * expect(getByRole('button').toBeEnabled()\n */\n toBeEnabled(): R;\n\n /**\n * Assert whether a host element is expanded based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeexpanded)\n *\n * @see {@link toBeCollapsed} for inverse matcher.\n *\n * @example\n * <View testID=\"details\" aria-expanded />\n *\n * expect(getByTestId('details').toBeExpanded()\n */\n toBeExpanded(): R;\n\n /**\n * Assert whether a host element is partially checked based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobechecked)\n *\n * @see {@link toBeChecked} for related matcher.\n *\n * @example\n * <View accessible role=\"checkbox\" aria-checked=\"mixed\" aria-label=\"Enable\" />\n *\n * expect(getByRole('checkbox', { name: \"Enable\" })).toBePartiallyChecked()\n */\n toBePartiallyChecked(): R;\n\n /**\n * Assert whether a host element is selected based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeselected)\n *\n * @example\n * <View testID=\"view\" aria-selected />\n *\n * expect(getByTestId('view')).toBeSelected()\n */\n toBeSelected(): R;\n\n /**\n * Assert whether a host element is visible based on style and accessibility props.\n *\n * This matcher will check ancestor elements for their visibility as well.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobevisible)\n *\n * @example\n * <View testID=\"visible\" />\n * <View testID=\"not-visible\" style={{ display: 'none' }} />\n *\n * expect(getByTestId('visible')).toBeVisible()\n * expect(getByTestId('not-visible')).not.toBeVisible()\n */\n toBeVisible(): R;\n\n /**\n * Assert whether a host element contains another host element.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tocontainelement)\n *\n * @example\n * <View testID=\"outer\">\n * <View testID=\"inner\" />\n * </View>\n *\n * expect(getByTestId('outer')).toContainElement(getByTestId('inner'));\n */\n toContainElement(element: ReactTestInstance | null): R;\n\n /**\n * Assert whether a host element has a given accessbility value.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveaccessibilityvalue)\n *\n *\n * @example\n * <View testID=\"view\" aria-valuetext=\"33%\" />\n *\n * expect(getByTestId('view')).toHaveAccessibilityValue({ text: '33%' });\n */\n toHaveAccessibilityValue(expectedValue: AccessibilityValueMatcher): R;\n\n /**\n * Assert whether a host element has a given accessibile name based on the accessibility label or text content.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveaccessiblename)\n *\n * @example\n * <View testID=\"view\" aria-label=\"Hello\" />\n *\n * expect(getByTestId('view')).toHaveAccessibleName('Hello');\n */\n toHaveAccessibleName(expectedName?: TextMatch, options?: TextMatchOptions): R;\n\n /**\n * Assert whether a host `TextInput` element has a given display value based on `value` and `defaultValue` props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavedisplayvalue)\n *\n * @example\n * <TextInput testID=\"input\" value=\"Hello\" />\n *\n * expect(getByTestId('input')).toHaveDisplayValue('Hello');\n */\n toHaveDisplayValue(expectedValue: TextMatch, options?: TextMatchOptions): R;\n\n /**\n * Assert whether a host element has a given prop.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveprop)\n *\n * @example\n * <Text testID=\"text\" numberOfLines={1]} />\n *\n * expect(getByTestId('text')).toHaveProp('numberOfLines');\n * expect(getByTestId('text')).toHaveProp('numberOfLines', 1);\n */\n toHaveProp(name: string, expectedValue?: unknown): R;\n\n /**\n * Assert whether a host element has a given style.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavestyle)\n *\n * @example\n * <View testID=\"view\" style={{ width: '100%' }} />\n *\n * expect(getByTestId('view')).toHaveStyle({ width: '100%' });\n * expect(getByTestId('view')).not.toHaveStyle({ width: '50%' });\n */\n toHaveStyle(style: StyleProp<Style>): R;\n\n /**\n * Assert whether a host element has a given text content.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavetextcontent)\n *\n * @example\n * <View testID=\"view\">\n * <Text>Hello World</Text>\n * </View>\n *\n * expect(getByTestId('view')).toHaveTextContent('Hello World');\n * expect(getByTestId('view')).toHaveTextContent('Hello', { exact: false }});\n * expect(getByTestId('view')).toHaveTextContent(/hello/i);\n * expect(getByTestId('view')).not.toHaveTextContent('Hello');\n */\n toHaveTextContent(expectedText: TextMatch, options?: TextMatchOptions): R;\n}\n\n// Implicit Jest global `expect`.\ndeclare global {\n namespace jest {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface Matchers<R, T = {}> extends JestNativeMatchers<R> {}\n }\n}\n\n// Explicit `@jest/globals` `expect` matchers.\n// @ts-ignore\ndeclare module '@jest/expect' {\n interface Matchers<R extends void | Promise<void>>\n extends JestNativeMatchers<R> {}\n}\n"],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/react-native",
3
- "version": "12.4.2",
3
+ "version": "12.4.3",
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",