@testing-library/react-native 9.0.0 → 9.1.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.
@@ -39,11 +39,13 @@ const getChildrenAsText = (children, TextComponent) => {
39
39
  // has no text. In such situations, react-test-renderer will traverse down
40
40
  // this tree in a separate call and run this query again. As a result, the
41
41
  // query will match the deepest text node that matches requested text.
42
- if ((0, _filterNodeByType.filterNodeByType)(child, TextComponent) && textContent.length === 0) {
42
+ if ((0, _filterNodeByType.filterNodeByType)(child, TextComponent)) {
43
43
  return;
44
44
  }
45
45
 
46
- getChildrenAsText(child.props.children, TextComponent);
46
+ if ((0, _filterNodeByType.filterNodeByType)(child, React.Fragment)) {
47
+ textContent.push(...getChildrenAsText(child.props.children, TextComponent));
48
+ }
47
49
  }
48
50
  });
49
51
  return textContent;
@@ -30,11 +30,15 @@ const getChildrenAsText = (children, TextComponent) => {
30
30
  // has no text. In such situations, react-test-renderer will traverse down
31
31
  // this tree in a separate call and run this query again. As a result, the
32
32
  // query will match the deepest text node that matches requested text.
33
- if (filterNodeByType(child, TextComponent) && textContent.length === 0) {
33
+ if (filterNodeByType(child, TextComponent)) {
34
34
  return;
35
35
  }
36
36
 
37
- getChildrenAsText(child.props.children, TextComponent);
37
+ if (filterNodeByType(child, React.Fragment)) {
38
+ textContent.push(
39
+ ...getChildrenAsText(child.props.children, TextComponent)
40
+ );
41
+ }
38
42
  }
39
43
  });
40
44
 
package/build/waitFor.js CHANGED
@@ -33,7 +33,8 @@ function checkReactVersionAtLeast(major, minor) {
33
33
  function waitForInternal(expectation, {
34
34
  timeout = DEFAULT_TIMEOUT,
35
35
  interval = DEFAULT_INTERVAL,
36
- stackTraceError
36
+ stackTraceError,
37
+ onTimeout
37
38
  }) {
38
39
  if (typeof expectation !== 'function') {
39
40
  throw new TypeError('Received `expectation` arg must be a function');
@@ -173,6 +174,10 @@ function waitForInternal(expectation, {
173
174
  }
174
175
  }
175
176
 
177
+ if (typeof onTimeout === 'function') {
178
+ onTimeout(error);
179
+ }
180
+
176
181
  onDone(error, null);
177
182
  }
178
183
  });
@@ -29,6 +29,7 @@ export type WaitForOptions = {
29
29
  timeout?: number,
30
30
  interval?: number,
31
31
  stackTraceError?: ErrorWithStack,
32
+ onTimeout?: (error: Error) => Error,
32
33
  };
33
34
 
34
35
  function waitForInternal<T>(
@@ -37,6 +38,7 @@ function waitForInternal<T>(
37
38
  timeout = DEFAULT_TIMEOUT,
38
39
  interval = DEFAULT_INTERVAL,
39
40
  stackTraceError,
41
+ onTimeout,
40
42
  }: WaitForOptions
41
43
  ): Promise<T> {
42
44
  if (typeof expectation !== 'function') {
@@ -179,6 +181,9 @@ function waitForInternal<T>(
179
181
  copyStackTrace(error, stackTraceError);
180
182
  }
181
183
  }
184
+ if (typeof onTimeout === 'function') {
185
+ onTimeout(error);
186
+ }
182
187
  onDone(error, null);
183
188
  }
184
189
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/react-native",
3
- "version": "9.0.0",
3
+ "version": "9.1.0",
4
4
  "description": "Simple and complete React Native testing utilities that encourage good testing practices.",
5
5
  "main": "build/index.js",
6
6
  "typings": "./typings/index.d.ts",
@@ -388,6 +388,7 @@ type TextMatchOptions = {
388
388
  type WaitForOptions = {
389
389
  timeout?: number;
390
390
  interval?: number;
391
+ onTimeout?: (error: Error) => Error;
391
392
  };
392
393
 
393
394
  export type WaitForFunction = <T = any>(