@testing-library/react-native 11.3.0 → 11.4.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 (97) hide show
  1. package/README.md +3 -0
  2. package/build/act.js +9 -15
  3. package/build/act.js.map +1 -1
  4. package/build/cleanup.js +0 -4
  5. package/build/cleanup.js.map +1 -1
  6. package/build/config.d.ts +5 -0
  7. package/build/config.js +4 -5
  8. package/build/config.js.map +1 -1
  9. package/build/fireEvent.js +3 -31
  10. package/build/fireEvent.js.map +1 -1
  11. package/build/flushMicroTasks.js +0 -3
  12. package/build/flushMicroTasks.js.map +1 -1
  13. package/build/helpers/accessiblity.d.ts +3 -0
  14. package/build/helpers/accessiblity.js +14 -20
  15. package/build/helpers/accessiblity.js.map +1 -1
  16. package/build/helpers/component-tree.js +6 -27
  17. package/build/helpers/component-tree.js.map +1 -1
  18. package/build/helpers/debugDeep.d.ts +5 -1
  19. package/build/helpers/debugDeep.js +7 -6
  20. package/build/helpers/debugDeep.js.map +1 -1
  21. package/build/helpers/debugShallow.js +0 -5
  22. package/build/helpers/debugShallow.js.map +1 -1
  23. package/build/helpers/errors.js +4 -25
  24. package/build/helpers/errors.js.map +1 -1
  25. package/build/helpers/filterNodeByType.js +0 -2
  26. package/build/helpers/filterNodeByType.js.map +1 -1
  27. package/build/helpers/format.d.ts +5 -1
  28. package/build/helpers/format.js +17 -7
  29. package/build/helpers/format.js.map +1 -1
  30. package/build/helpers/matchers/accessibilityState.d.ts +3 -0
  31. package/build/helpers/matchers/accessibilityState.js +28 -0
  32. package/build/helpers/matchers/accessibilityState.js.map +1 -0
  33. package/build/helpers/matchers/matchArrayProp.js +0 -3
  34. package/build/helpers/matchers/matchArrayProp.js.map +1 -1
  35. package/build/helpers/matchers/matchObjectProp.js +0 -2
  36. package/build/helpers/matchers/matchObjectProp.js.map +1 -1
  37. package/build/helpers/matchers/matchStringProp.js +0 -3
  38. package/build/helpers/matchers/matchStringProp.js.map +1 -1
  39. package/build/helpers/stringValidation.js +0 -7
  40. package/build/helpers/stringValidation.js.map +1 -1
  41. package/build/helpers/timers.js +10 -21
  42. package/build/helpers/timers.js.map +1 -1
  43. package/build/index.flow.js +66 -21
  44. package/build/index.js +0 -6
  45. package/build/index.js.map +1 -1
  46. package/build/matches.js +2 -4
  47. package/build/matches.js.map +1 -1
  48. package/build/pure.js +0 -13
  49. package/build/pure.js.map +1 -1
  50. package/build/queries/a11yState.js +15 -13
  51. package/build/queries/a11yState.js.map +1 -1
  52. package/build/queries/a11yValue.js +0 -8
  53. package/build/queries/a11yValue.js.map +1 -1
  54. package/build/queries/displayValue.js +0 -11
  55. package/build/queries/displayValue.js.map +1 -1
  56. package/build/queries/hintText.d.ts +19 -18
  57. package/build/queries/hintText.js +10 -11
  58. package/build/queries/hintText.js.map +1 -1
  59. package/build/queries/labelText.d.ts +7 -6
  60. package/build/queries/labelText.js +10 -11
  61. package/build/queries/labelText.js.map +1 -1
  62. package/build/queries/makeQueries.d.ts +3 -3
  63. package/build/queries/makeQueries.js +40 -24
  64. package/build/queries/makeQueries.js.map +1 -1
  65. package/build/queries/placeholderText.js +0 -11
  66. package/build/queries/placeholderText.js.map +1 -1
  67. package/build/queries/role.d.ts +3 -2
  68. package/build/queries/role.js +23 -13
  69. package/build/queries/role.js.map +1 -1
  70. package/build/queries/testId.js +0 -9
  71. package/build/queries/testId.js.map +1 -1
  72. package/build/queries/text.js +0 -24
  73. package/build/queries/text.js.map +1 -1
  74. package/build/queries/unsafeProps.js +2 -11
  75. package/build/queries/unsafeProps.js.map +1 -1
  76. package/build/queries/unsafeType.js +2 -9
  77. package/build/queries/unsafeType.js.map +1 -1
  78. package/build/react-versions.js +0 -4
  79. package/build/react-versions.js.map +1 -1
  80. package/build/render.d.ts +32 -31
  81. package/build/render.js +21 -31
  82. package/build/render.js.map +1 -1
  83. package/build/renderHook.js +2 -12
  84. package/build/renderHook.js.map +1 -1
  85. package/build/screen.js +0 -6
  86. package/build/screen.js.map +1 -1
  87. package/build/shallow.js +0 -6
  88. package/build/shallow.js.map +1 -1
  89. package/build/waitFor.js +29 -52
  90. package/build/waitFor.js.map +1 -1
  91. package/build/waitForElementToBeRemoved.js +2 -11
  92. package/build/waitForElementToBeRemoved.js.map +1 -1
  93. package/build/within.d.ts +30 -30
  94. package/build/within.js +2 -14
  95. package/build/within.js.map +1 -1
  96. package/package.json +9 -8
  97. package/typings/index.flow.js +66 -21
@@ -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":"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"}
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":"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"}
@@ -1,5 +1,9 @@
1
1
  import type { ReactTestRendererJSON } from 'react-test-renderer';
2
+ import { FormatOptions } from './format';
3
+ export declare 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,CACb,kCADa,EAEb,EAFa,CAAf;EAID,CAND,MAMO,IAAIL,KAAK,IAAI,OAAOA,KAAP,KAAiB,QAA9B,EAAwC;IAC7CI,YAAY,GAAGJ,KAAK,CAACM,QAAN,EAAf;EACD,CAFM,MAEA;IACLF,YAAY,GAAG,sBAAf;EACD;;EAED,IAAIF,IAAI,IAAIC,KAAZ,EAAmB;IACjBC,YAAY,IAAK,SAAQF,IAAK,IAAG,IAAAK,qBAAA,EAAaJ,KAAb,EAAoB;MAAEK,GAAG,EAAE;IAAP,CAApB,CAAmC,EAApE;EACD;;EACD,OAAOJ,YAAP;AACD,CAxBM;;;;AA0BA,MAAMK,kBAAkB,GAAG,CAChCT,KADgC,EAEhCH,QAFgC,KAGvB;EACT,IAAIG,KAAK,YAAYN,KAArB,EAA4B;IAC1B,IAAIM,KAAK,CAACJ,OAAN,CAAcc,QAAd,CAAuB,oBAAvB,CAAJ,EAAkD;MAChD,OAAO,IAAP;IACD;;IACD,MAAM,IAAIjB,cAAJ,CAAmBO,KAAK,CAACJ,OAAzB,EAAkCC,QAAlC,CAAN;EACD;;EAED,MAAM,IAAIJ,cAAJ,EACJ;EACA;EACC,qCAAoC,OAAOO,KAAM,YAChDA,KAD2D,EAE1DM,QAF0D,IAE7C,EALZ,EAMJT,QANI,CAAN;AAQD,CAnBM;;;;AAqBA,SAASc,cAAT,CAAwBC,MAAxB,EAAyCC,gBAAzC,EAAkE;EACvE,IAAID,MAAM,YAAYlB,KAAlB,IAA2BmB,gBAAgB,CAACC,KAAhD,EAAuD;IACrDF,MAAM,CAACE,KAAP,GAAeD,gBAAgB,CAACC,KAAjB,CAAuBT,OAAvB,CACbQ,gBAAgB,CAACjB,OADJ,EAEbgB,MAAM,CAAChB,OAFM,CAAf;EAID;AACF;;AAED,MAAMmB,MAA2C,GAAG,EAApD;;AAEO,SAASC,uBAAT,CAAiCC,YAAjC,EAAuD;EAC5D,IAAIF,MAAM,CAACE,YAAD,CAAV,EAA0B;IACxB;EACD,CAH2D,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,CACN,gFACCM,KAAK,YAAYN,KAAK,GAAGM,KAAK,CAACJ,OAAO,GAAG,EAC1C,EAAC,CACH;AAAC;AAEG,MAAMK,mBAAmB,GAAG,CAGjCD,KAAc,EACdE,IAAa,EACbC,KAAe,KACJ;EACX,IAAIC,YAAoB;EACxB,IAAIJ,KAAK,YAAYN,KAAK,EAAE;IAC1B;IACAU,YAAY,GAAGJ,KAAK,CAACJ,OAAO,CAACS,OAAO,CAClC,kCAAkC,EAClC,EAAE,CACH;EACH,CAAC,MAAM,IAAIL,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7CI,YAAY,GAAGJ,KAAK,CAACM,QAAQ,EAAE;EACjC,CAAC,MAAM;IACLF,YAAY,GAAG,sBAAsB;EACvC;EAEA,IAAIF,IAAI,IAAIC,KAAK,EAAE;IACjBC,YAAY,IAAK,SAAQF,IAAK,IAAG,IAAAK,qBAAY,EAACJ,KAAK,EAAE;MAAEK,GAAG,EAAE;IAAK,CAAC,CAAE,EAAC;EACvE;EACA,OAAOJ,YAAY;AACrB,CAAC;AAAC;AAEK,MAAMK,kBAAkB,GAAG,CAChCT,KAAc,EACdH,QAAkB,KACT;EACT,IAAIG,KAAK,YAAYN,KAAK,EAAE;IAC1B,IAAIM,KAAK,CAACJ,OAAO,CAACc,QAAQ,CAAC,oBAAoB,CAAC,EAAE;MAChD,OAAO,IAAI;IACb;IACA,MAAM,IAAIjB,cAAc,CAACO,KAAK,CAACJ,OAAO,EAAEC,QAAQ,CAAC;EACnD;EAEA,MAAM,IAAIJ,cAAc;EACtB;EACA;EACC,qCAAoC,OAAOO,KAAM,YAChDA,KAAK,EACJM,QAAQ,IAAK,EAAC,EACjBT,QAAQ,CACT;AACH,CAAC;AAAC;AAEK,SAASc,cAAc,CAACC,MAAe,EAAEC,gBAAuB,EAAE;EACvE,IAAID,MAAM,YAAYlB,KAAK,IAAImB,gBAAgB,CAACC,KAAK,EAAE;IACrDF,MAAM,CAACE,KAAK,GAAGD,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"}
@@ -1,3 +1,7 @@
1
1
  import type { ReactTestRendererJSON } from 'react-test-renderer';
2
- declare const format: (input: ReactTestRendererJSON | ReactTestRendererJSON[]) => string;
2
+ declare type MapPropsFunction = (props: Record<string, unknown>, node: ReactTestRendererJSON) => Record<string, unknown>;
3
+ export declare 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,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"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.matchArrayProp = matchArrayProp;
7
-
8
7
  /**
9
8
  * Matches whether given array prop contains the given value, or all given values.
10
9
  *
@@ -16,11 +15,9 @@ function matchArrayProp(prop, matcher) {
16
15
  if (!prop || matcher.length === 0) {
17
16
  return false;
18
17
  }
19
-
20
18
  if (typeof matcher === 'string') {
21
19
  return prop.includes(matcher);
22
20
  }
23
-
24
21
  return matcher.every(e => prop.includes(e));
25
22
  }
26
23
  //# sourceMappingURL=matchArrayProp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"matchArrayProp.js","names":["matchArrayProp","prop","matcher","length","includes","every","e"],"sources":["../../../src/helpers/matchers/matchArrayProp.ts"],"sourcesContent":["/**\n * Matches whether given array prop contains the given value, or all given values.\n *\n * @param prop - The array prop to match.\n * @param matcher - The value or values to be included in the array.\n * @returns Whether the array prop contains the given value, or all given values.\n */\nexport function matchArrayProp(\n prop: Array<string> | undefined,\n matcher: string | Array<string>\n): boolean {\n if (!prop || matcher.length === 0) {\n return false;\n }\n\n if (typeof matcher === 'string') {\n return prop.includes(matcher);\n }\n\n return matcher.every((e) => prop.includes(e));\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CACLC,IADK,EAELC,OAFK,EAGI;EACT,IAAI,CAACD,IAAD,IAASC,OAAO,CAACC,MAAR,KAAmB,CAAhC,EAAmC;IACjC,OAAO,KAAP;EACD;;EAED,IAAI,OAAOD,OAAP,KAAmB,QAAvB,EAAiC;IAC/B,OAAOD,IAAI,CAACG,QAAL,CAAcF,OAAd,CAAP;EACD;;EAED,OAAOA,OAAO,CAACG,KAAR,CAAeC,CAAD,IAAOL,IAAI,CAACG,QAAL,CAAcE,CAAd,CAArB,CAAP;AACD"}
1
+ {"version":3,"file":"matchArrayProp.js","names":["matchArrayProp","prop","matcher","length","includes","every","e"],"sources":["../../../src/helpers/matchers/matchArrayProp.ts"],"sourcesContent":["/**\n * Matches whether given array prop contains the given value, or all given values.\n *\n * @param prop - The array prop to match.\n * @param matcher - The value or values to be included in the array.\n * @returns Whether the array prop contains the given value, or all given values.\n */\nexport function matchArrayProp(\n prop: Array<string> | undefined,\n matcher: string | Array<string>\n): boolean {\n if (!prop || matcher.length === 0) {\n return false;\n }\n\n if (typeof matcher === 'string') {\n return prop.includes(matcher);\n }\n\n return matcher.every((e) => prop.includes(e));\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAc,CAC5BC,IAA+B,EAC/BC,OAA+B,EACtB;EACT,IAAI,CAACD,IAAI,IAAIC,OAAO,CAACC,MAAM,KAAK,CAAC,EAAE;IACjC,OAAO,KAAK;EACd;EAEA,IAAI,OAAOD,OAAO,KAAK,QAAQ,EAAE;IAC/B,OAAOD,IAAI,CAACG,QAAQ,CAACF,OAAO,CAAC;EAC/B;EAEA,OAAOA,OAAO,CAACG,KAAK,CAAEC,CAAC,IAAKL,IAAI,CAACG,QAAQ,CAACE,CAAC,CAAC,CAAC;AAC/C"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.matchObjectProp = matchObjectProp;
7
-
8
7
  /**
9
8
  * check that each key value pair of the objects match
10
9
  * BE CAREFUL it works only for 1 level deep key value pairs
@@ -21,7 +20,6 @@ function matchObjectProp(prop, matcher) {
21
20
  if (!prop || Object.keys(matcher).length === 0) {
22
21
  return false;
23
22
  }
24
-
25
23
  return Object.keys(prop).length !== 0 && Object.keys(matcher).every(key => prop[key] === matcher[key]);
26
24
  }
27
25
  //# sourceMappingURL=matchObjectProp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"matchObjectProp.js","names":["matchObjectProp","prop","matcher","Object","keys","length","every","key"],"sources":["../../../src/helpers/matchers/matchObjectProp.ts"],"sourcesContent":["/**\n * check that each key value pair of the objects match\n * BE CAREFUL it works only for 1 level deep key value pairs\n * won't work for nested objects\n */\n\n/**\n * Matches whether given object prop contains all key/value pairs.\n * @param prop - The object prop to match.\n * @param matcher - The key/value pairs to be included in the object.\n * @returns Whether the object prop contains all key/value pairs.\n */\nexport function matchObjectProp<T extends Record<string, unknown>>(\n prop: T | undefined,\n matcher: T\n): boolean {\n if (!prop || Object.keys(matcher).length === 0) {\n return false;\n }\n\n return (\n Object.keys(prop).length !== 0 &&\n Object.keys(matcher).every((key) => prop[key] === matcher[key])\n );\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,CACLC,IADK,EAELC,OAFK,EAGI;EACT,IAAI,CAACD,IAAD,IAASE,MAAM,CAACC,IAAP,CAAYF,OAAZ,EAAqBG,MAArB,KAAgC,CAA7C,EAAgD;IAC9C,OAAO,KAAP;EACD;;EAED,OACEF,MAAM,CAACC,IAAP,CAAYH,IAAZ,EAAkBI,MAAlB,KAA6B,CAA7B,IACAF,MAAM,CAACC,IAAP,CAAYF,OAAZ,EAAqBI,KAArB,CAA4BC,GAAD,IAASN,IAAI,CAACM,GAAD,CAAJ,KAAcL,OAAO,CAACK,GAAD,CAAzD,CAFF;AAID"}
1
+ {"version":3,"file":"matchObjectProp.js","names":["matchObjectProp","prop","matcher","Object","keys","length","every","key"],"sources":["../../../src/helpers/matchers/matchObjectProp.ts"],"sourcesContent":["/**\n * check that each key value pair of the objects match\n * BE CAREFUL it works only for 1 level deep key value pairs\n * won't work for nested objects\n */\n\n/**\n * Matches whether given object prop contains all key/value pairs.\n * @param prop - The object prop to match.\n * @param matcher - The key/value pairs to be included in the object.\n * @returns Whether the object prop contains all key/value pairs.\n */\nexport function matchObjectProp<T extends Record<string, unknown>>(\n prop: T | undefined,\n matcher: T\n): boolean {\n if (!prop || Object.keys(matcher).length === 0) {\n return false;\n }\n\n return (\n Object.keys(prop).length !== 0 &&\n Object.keys(matcher).every((key) => prop[key] === matcher[key])\n );\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAe,CAC7BC,IAAmB,EACnBC,OAAU,EACD;EACT,IAAI,CAACD,IAAI,IAAIE,MAAM,CAACC,IAAI,CAACF,OAAO,CAAC,CAACG,MAAM,KAAK,CAAC,EAAE;IAC9C,OAAO,KAAK;EACd;EAEA,OACEF,MAAM,CAACC,IAAI,CAACH,IAAI,CAAC,CAACI,MAAM,KAAK,CAAC,IAC9BF,MAAM,CAACC,IAAI,CAACF,OAAO,CAAC,CAACI,KAAK,CAAEC,GAAG,IAAKN,IAAI,CAACM,GAAG,CAAC,KAAKL,OAAO,CAACK,GAAG,CAAC,CAAC;AAEnE"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.matchStringProp = matchStringProp;
7
-
8
7
  /**
9
8
  * Matches the given string property again string or regex matcher.
10
9
  *
@@ -16,11 +15,9 @@ function matchStringProp(prop, matcher) {
16
15
  if (!prop) {
17
16
  return false;
18
17
  }
19
-
20
18
  if (typeof matcher === 'string') {
21
19
  return prop === matcher;
22
20
  }
23
-
24
21
  return prop.match(matcher) != null;
25
22
  }
26
23
  //# sourceMappingURL=matchStringProp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"matchStringProp.js","names":["matchStringProp","prop","matcher","match"],"sources":["../../../src/helpers/matchers/matchStringProp.ts"],"sourcesContent":["import { TextMatch } from '../../matches';\n\n/**\n * Matches the given string property again string or regex matcher.\n *\n * @param prop - The string prop to match.\n * @param matcher - The string or regex to match.\n * @returns - Whether the string prop matches the given string or regex.\n */\nexport function matchStringProp(\n prop: string | undefined,\n matcher: TextMatch\n): boolean {\n if (!prop) {\n return false;\n }\n\n if (typeof matcher === 'string') {\n return prop === matcher;\n }\n\n return prop.match(matcher) != null;\n}\n"],"mappings":";;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,CACLC,IADK,EAELC,OAFK,EAGI;EACT,IAAI,CAACD,IAAL,EAAW;IACT,OAAO,KAAP;EACD;;EAED,IAAI,OAAOC,OAAP,KAAmB,QAAvB,EAAiC;IAC/B,OAAOD,IAAI,KAAKC,OAAhB;EACD;;EAED,OAAOD,IAAI,CAACE,KAAL,CAAWD,OAAX,KAAuB,IAA9B;AACD"}
1
+ {"version":3,"file":"matchStringProp.js","names":["matchStringProp","prop","matcher","match"],"sources":["../../../src/helpers/matchers/matchStringProp.ts"],"sourcesContent":["import { TextMatch } from '../../matches';\n\n/**\n * Matches the given string property again string or regex matcher.\n *\n * @param prop - The string prop to match.\n * @param matcher - The string or regex to match.\n * @returns - Whether the string prop matches the given string or regex.\n */\nexport function matchStringProp(\n prop: string | undefined,\n matcher: TextMatch\n): boolean {\n if (!prop) {\n return false;\n }\n\n if (typeof matcher === 'string') {\n return prop === matcher;\n }\n\n return prop.match(matcher) != null;\n}\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAe,CAC7BC,IAAwB,EACxBC,OAAkB,EACT;EACT,IAAI,CAACD,IAAI,EAAE;IACT,OAAO,KAAK;EACd;EAEA,IAAI,OAAOC,OAAO,KAAK,QAAQ,EAAE;IAC/B,OAAOD,IAAI,KAAKC,OAAO;EACzB;EAEA,OAAOD,IAAI,CAACE,KAAK,CAACD,OAAO,CAAC,IAAI,IAAI;AACpC"}
@@ -4,25 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.validateStringsRenderedWithinText = void 0;
7
-
8
7
  const validateStringsRenderedWithinText = rendererJSON => {
9
8
  if (!rendererJSON) return;
10
-
11
9
  if (Array.isArray(rendererJSON)) {
12
10
  rendererJSON.forEach(validateStringsRenderedWithinTextForNode);
13
11
  return;
14
12
  }
15
-
16
13
  return validateStringsRenderedWithinTextForNode(rendererJSON);
17
14
  };
18
-
19
15
  exports.validateStringsRenderedWithinText = validateStringsRenderedWithinText;
20
-
21
16
  const validateStringsRenderedWithinTextForNode = node => {
22
17
  if (typeof node === 'string') {
23
18
  return;
24
19
  }
25
-
26
20
  if (node.type !== 'Text') {
27
21
  node.children?.forEach(child => {
28
22
  if (typeof child === 'string') {
@@ -30,7 +24,6 @@ const validateStringsRenderedWithinTextForNode = node => {
30
24
  }
31
25
  });
32
26
  }
33
-
34
27
  if (node.children) {
35
28
  node.children.forEach(validateStringsRenderedWithinTextForNode);
36
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"stringValidation.js","names":["validateStringsRenderedWithinText","rendererJSON","Array","isArray","forEach","validateStringsRenderedWithinTextForNode","node","type","children","child","Error"],"sources":["../../src/helpers/stringValidation.ts"],"sourcesContent":["import { ReactTestRendererNode } from 'react-test-renderer';\n\nexport const validateStringsRenderedWithinText = (\n rendererJSON: ReactTestRendererNode | Array<ReactTestRendererNode> | null\n) => {\n if (!rendererJSON) return;\n\n if (Array.isArray(rendererJSON)) {\n rendererJSON.forEach(validateStringsRenderedWithinTextForNode);\n return;\n }\n\n return validateStringsRenderedWithinTextForNode(rendererJSON);\n};\n\nconst validateStringsRenderedWithinTextForNode = (\n node: ReactTestRendererNode\n) => {\n if (typeof node === 'string') {\n return;\n }\n\n if (node.type !== 'Text') {\n node.children?.forEach((child) => {\n if (typeof child === 'string') {\n throw new Error(\n `Invariant Violation: Text strings must be rendered within a <Text> component. Detected attempt to render \"${child}\" string within a <${node.type}> component.`\n );\n }\n });\n }\n\n if (node.children) {\n node.children.forEach(validateStringsRenderedWithinTextForNode);\n }\n};\n"],"mappings":";;;;;;;AAEO,MAAMA,iCAAiC,GAC5CC,YAD+C,IAE5C;EACH,IAAI,CAACA,YAAL,EAAmB;;EAEnB,IAAIC,KAAK,CAACC,OAAN,CAAcF,YAAd,CAAJ,EAAiC;IAC/BA,YAAY,CAACG,OAAb,CAAqBC,wCAArB;IACA;EACD;;EAED,OAAOA,wCAAwC,CAACJ,YAAD,CAA/C;AACD,CAXM;;;;AAaP,MAAMI,wCAAwC,GAC5CC,IAD+C,IAE5C;EACH,IAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;IAC5B;EACD;;EAED,IAAIA,IAAI,CAACC,IAAL,KAAc,MAAlB,EAA0B;IACxBD,IAAI,CAACE,QAAL,EAAeJ,OAAf,CAAwBK,KAAD,IAAW;MAChC,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;QAC7B,MAAM,IAAIC,KAAJ,CACH,6GAA4GD,KAAM,sBAAqBH,IAAI,CAACC,IAAK,cAD9I,CAAN;MAGD;IACF,CAND;EAOD;;EAED,IAAID,IAAI,CAACE,QAAT,EAAmB;IACjBF,IAAI,CAACE,QAAL,CAAcJ,OAAd,CAAsBC,wCAAtB;EACD;AACF,CApBD"}
1
+ {"version":3,"file":"stringValidation.js","names":["validateStringsRenderedWithinText","rendererJSON","Array","isArray","forEach","validateStringsRenderedWithinTextForNode","node","type","children","child","Error"],"sources":["../../src/helpers/stringValidation.ts"],"sourcesContent":["import { ReactTestRendererNode } from 'react-test-renderer';\n\nexport const validateStringsRenderedWithinText = (\n rendererJSON: ReactTestRendererNode | Array<ReactTestRendererNode> | null\n) => {\n if (!rendererJSON) return;\n\n if (Array.isArray(rendererJSON)) {\n rendererJSON.forEach(validateStringsRenderedWithinTextForNode);\n return;\n }\n\n return validateStringsRenderedWithinTextForNode(rendererJSON);\n};\n\nconst validateStringsRenderedWithinTextForNode = (\n node: ReactTestRendererNode\n) => {\n if (typeof node === 'string') {\n return;\n }\n\n if (node.type !== 'Text') {\n node.children?.forEach((child) => {\n if (typeof child === 'string') {\n throw new Error(\n `Invariant Violation: Text strings must be rendered within a <Text> component. Detected attempt to render \"${child}\" string within a <${node.type}> component.`\n );\n }\n });\n }\n\n if (node.children) {\n node.children.forEach(validateStringsRenderedWithinTextForNode);\n }\n};\n"],"mappings":";;;;;;AAEO,MAAMA,iCAAiC,GAC5CC,YAAyE,IACtE;EACH,IAAI,CAACA,YAAY,EAAE;EAEnB,IAAIC,KAAK,CAACC,OAAO,CAACF,YAAY,CAAC,EAAE;IAC/BA,YAAY,CAACG,OAAO,CAACC,wCAAwC,CAAC;IAC9D;EACF;EAEA,OAAOA,wCAAwC,CAACJ,YAAY,CAAC;AAC/D,CAAC;AAAC;AAEF,MAAMI,wCAAwC,GAC5CC,IAA2B,IACxB;EACH,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B;EACF;EAEA,IAAIA,IAAI,CAACC,IAAI,KAAK,MAAM,EAAE;IACxBD,IAAI,CAACE,QAAQ,EAAEJ,OAAO,CAAEK,KAAK,IAAK;MAChC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;QAC7B,MAAM,IAAIC,KAAK,CACZ,6GAA4GD,KAAM,sBAAqBH,IAAI,CAACC,IAAK,cAAa,CAChK;MACH;IACF,CAAC,CAAC;EACJ;EAEA,IAAID,IAAI,CAACE,QAAQ,EAAE;IACjBF,IAAI,CAACE,QAAQ,CAACJ,OAAO,CAACC,wCAAwC,CAAC;EACjE;AACF,CAAC"}
@@ -7,53 +7,46 @@ exports.jestFakeTimersAreEnabled = exports.clearTimeout = void 0;
7
7
  exports.runWithRealTimers = runWithRealTimers;
8
8
  exports.setTimeout = exports.setImmediate = void 0;
9
9
  // Most content of this file sourced directly from https://github.com/testing-library/dom-testing-library/blob/main/src/helpers.js
10
-
11
10
  /* globals jest */
12
11
  const globalObj = typeof window === 'undefined' ? global : window;
13
-
14
12
  // Currently this fn only supports jest timers, but it could support other test runners in the future.
15
13
  function runWithRealTimers(callback) {
16
14
  const fakeTimersType = getJestFakeTimersType();
17
-
18
15
  if (fakeTimersType) {
19
16
  jest.useRealTimers();
20
17
  }
21
-
22
18
  const callbackReturnValue = callback();
23
-
24
19
  if (fakeTimersType) {
25
20
  const fakeTimersConfig = getFakeTimersConfigFromType(fakeTimersType);
26
21
  jest.useFakeTimers(fakeTimersConfig);
27
22
  }
28
-
29
23
  return callbackReturnValue;
30
24
  }
31
-
32
25
  function getJestFakeTimersType() {
33
26
  // istanbul ignore if
34
27
  if (typeof jest === 'undefined' || typeof globalObj.setTimeout === 'undefined' || process.env.RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS) {
35
28
  return null;
36
29
  }
37
-
38
- if ( // @ts-expect-error jest mutates setTimeout
39
- typeof globalObj.setTimeout._isMockFunction !== 'undefined' && // @ts-expect-error jest mutates setTimeout
30
+ if (
31
+ // @ts-expect-error jest mutates setTimeout
32
+ typeof globalObj.setTimeout._isMockFunction !== 'undefined' &&
33
+ // @ts-expect-error jest mutates setTimeout
40
34
  globalObj.setTimeout._isMockFunction) {
41
35
  return 'legacy';
42
36
  }
43
-
44
- if ( // @ts-expect-error jest mutates setTimeout
37
+ if (
38
+ // @ts-expect-error jest mutates setTimeout
45
39
  typeof globalObj.setTimeout.clock !== 'undefined' && typeof jest.getRealSystemTime !== 'undefined') {
46
40
  try {
47
41
  // jest.getRealSystemTime is only supported for Jest's `modern` fake timers and otherwise throws
48
42
  jest.getRealSystemTime();
49
43
  return 'modern';
50
- } catch {// not using Jest's modern fake timers
44
+ } catch {
45
+ // not using Jest's modern fake timers
51
46
  }
52
47
  }
53
-
54
48
  return null;
55
49
  }
56
-
57
50
  function getFakeTimersConfigFromType(type) {
58
51
  return type === 'legacy' ? {
59
52
  legacyFakeTimers: true
@@ -61,16 +54,13 @@ function getFakeTimersConfigFromType(type) {
61
54
  legacyFakeTimers: false
62
55
  };
63
56
  }
57
+ const jestFakeTimersAreEnabled = () => Boolean(getJestFakeTimersType());
64
58
 
65
- const jestFakeTimersAreEnabled = () => Boolean(getJestFakeTimersType()); // we only run our tests in node, and setImmediate is supported in node.
66
-
67
-
59
+ // we only run our tests in node, and setImmediate is supported in node.
68
60
  exports.jestFakeTimersAreEnabled = jestFakeTimersAreEnabled;
69
-
70
61
  function setImmediatePolyfill(fn) {
71
62
  return globalObj.setTimeout(fn, 0);
72
63
  }
73
-
74
64
  function bindTimeFunctions() {
75
65
  return {
76
66
  clearTimeoutFn: globalObj.clearTimeout,
@@ -78,7 +68,6 @@ function bindTimeFunctions() {
78
68
  setTimeoutFn: globalObj.setTimeout
79
69
  };
80
70
  }
81
-
82
71
  const {
83
72
  clearTimeoutFn,
84
73
  setImmediateFn,