@testing-library/react-native 11.0.0 → 11.2.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.
- package/README.md +1 -1
- package/build/act.d.ts +8 -3
- package/build/act.js +73 -2
- package/build/act.js.map +1 -1
- package/build/cleanup.js.map +1 -1
- package/build/fireEvent.js +17 -7
- package/build/fireEvent.js.map +1 -1
- package/build/flushMicroTasks.js.map +1 -1
- package/build/helpers/accessiblity.d.ts +2 -0
- package/build/helpers/accessiblity.js +60 -0
- package/build/helpers/accessiblity.js.map +1 -0
- package/build/helpers/component-tree.d.ts +29 -0
- package/build/helpers/component-tree.js +90 -0
- package/build/helpers/component-tree.js.map +1 -0
- package/build/helpers/debugDeep.js.map +1 -1
- package/build/helpers/debugShallow.js.map +1 -1
- package/build/helpers/errors.d.ts +2 -2
- package/build/helpers/errors.js.map +1 -1
- package/build/helpers/filterNodeByType.d.ts +1 -1
- package/build/helpers/filterNodeByType.js.map +1 -1
- package/build/helpers/format.js.map +1 -1
- package/build/helpers/matchers/matchArrayProp.js.map +1 -1
- package/build/helpers/matchers/matchObjectProp.js.map +1 -1
- package/build/helpers/matchers/matchStringProp.js.map +1 -1
- package/build/helpers/stringValidation.d.ts +2 -0
- package/build/helpers/stringValidation.js +38 -0
- package/build/helpers/stringValidation.js.map +1 -0
- package/build/helpers/timers.js.map +1 -1
- package/build/index.flow.js +50 -31
- package/build/index.js +27 -11
- package/build/index.js.map +1 -1
- package/build/matches.js.map +1 -1
- package/build/pure.d.ts +5 -3
- package/build/pure.js +8 -0
- package/build/pure.js.map +1 -1
- package/build/queries/a11yState.js.map +1 -1
- package/build/queries/a11yValue.js.map +1 -1
- package/build/queries/displayValue.js.map +1 -1
- package/build/queries/hintText.js.map +1 -1
- package/build/queries/labelText.js.map +1 -1
- package/build/queries/makeQueries.js.map +1 -1
- package/build/queries/placeholderText.js.map +1 -1
- package/build/queries/role.d.ts +10 -6
- package/build/queries/role.js +13 -2
- package/build/queries/role.js.map +1 -1
- package/build/queries/testId.js.map +1 -1
- package/build/queries/text.js.map +1 -1
- package/build/queries/unsafeProps.js.map +1 -1
- package/build/queries/unsafeType.js.map +1 -1
- package/build/react-versions.d.ts +1 -0
- package/build/react-versions.js +19 -0
- package/build/react-versions.js.map +1 -0
- package/build/render.d.ts +21 -8
- package/build/render.js +37 -1
- package/build/render.js.map +1 -1
- package/build/renderHook.d.ts +3 -4
- package/build/renderHook.js.map +1 -1
- package/build/screen.js.map +1 -1
- package/build/shallow.js.map +1 -1
- package/build/waitFor.js +14 -11
- package/build/waitFor.js.map +1 -1
- package/build/waitForElementToBeRemoved.js.map +1 -1
- package/build/within.d.ts +18 -6
- package/build/within.js.map +1 -1
- package/package.json +22 -19
- package/typings/index.flow.js +50 -31
package/README.md
CHANGED
|
@@ -143,7 +143,7 @@ The [public API](https://callstack.github.io/react-native-testing-library/docs/a
|
|
|
143
143
|
|
|
144
144
|
## Troubleshooting
|
|
145
145
|
|
|
146
|
-
- [
|
|
146
|
+
- [Troubleshooting guide](https://callstack.github.io/react-native-testing-library/docs/troubleshooting)
|
|
147
147
|
|
|
148
148
|
## Related External Resources
|
|
149
149
|
|
package/build/act.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
declare global {
|
|
2
|
+
var IS_REACT_ACT_ENVIRONMENT: boolean | undefined;
|
|
3
|
+
}
|
|
4
|
+
declare function setIsReactActEnvironment(isReactActEnvironment: boolean | undefined): void;
|
|
5
|
+
declare function getIsReactActEnvironment(): boolean | undefined;
|
|
6
|
+
declare const act: (callback: () => void) => void;
|
|
7
|
+
export default act;
|
|
8
|
+
export { setIsReactActEnvironment as setReactActEnvironment, getIsReactActEnvironment, };
|
package/build/act.js
CHANGED
|
@@ -4,14 +4,85 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
exports.getIsReactActEnvironment = getIsReactActEnvironment;
|
|
8
|
+
exports.setReactActEnvironment = setIsReactActEnvironment;
|
|
7
9
|
|
|
8
10
|
var _reactTestRenderer = require("react-test-renderer");
|
|
9
11
|
|
|
12
|
+
var _reactVersions = require("./react-versions");
|
|
13
|
+
|
|
14
|
+
// This file and the act() implementation is sourced from react-testing-library
|
|
15
|
+
// https://github.com/testing-library/react-testing-library/blob/c80809a956b0b9f3289c4a6fa8b5e8cc72d6ef6d/src/act-compat.js
|
|
10
16
|
const actMock = callback => {
|
|
11
17
|
callback();
|
|
12
|
-
};
|
|
18
|
+
}; // See https://github.com/reactwg/react-18/discussions/102 for more context on global.IS_REACT_ACT_ENVIRONMENT
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
function setIsReactActEnvironment(isReactActEnvironment) {
|
|
22
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = isReactActEnvironment;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getIsReactActEnvironment() {
|
|
26
|
+
return globalThis.IS_REACT_ACT_ENVIRONMENT;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function withGlobalActEnvironment(actImplementation) {
|
|
30
|
+
return callback => {
|
|
31
|
+
const previousActEnvironment = getIsReactActEnvironment();
|
|
32
|
+
setIsReactActEnvironment(true); // this code is riddled with eslint disabling comments because this doesn't use real promises but eslint thinks we do
|
|
13
33
|
|
|
14
|
-
|
|
34
|
+
try {
|
|
35
|
+
// The return value of `act` is always a thenable.
|
|
36
|
+
let callbackNeedsToBeAwaited = false;
|
|
37
|
+
const actResult = actImplementation(() => {
|
|
38
|
+
const result = callback();
|
|
39
|
+
|
|
40
|
+
if (result !== null && typeof result === 'object' && // @ts-expect-error this should be a promise or thenable
|
|
41
|
+
// eslint-disable-next-line promise/prefer-await-to-then
|
|
42
|
+
typeof result.then === 'function') {
|
|
43
|
+
callbackNeedsToBeAwaited = true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return result;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
if (callbackNeedsToBeAwaited) {
|
|
50
|
+
const thenable = actResult;
|
|
51
|
+
return {
|
|
52
|
+
then: (resolve, reject) => {
|
|
53
|
+
// eslint-disable-next-line
|
|
54
|
+
thenable.then( // eslint-disable-next-line promise/always-return
|
|
55
|
+
returnValue => {
|
|
56
|
+
setIsReactActEnvironment(previousActEnvironment);
|
|
57
|
+
resolve(returnValue);
|
|
58
|
+
}, error => {
|
|
59
|
+
setIsReactActEnvironment(previousActEnvironment);
|
|
60
|
+
reject(error);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
} else {
|
|
65
|
+
setIsReactActEnvironment(previousActEnvironment);
|
|
66
|
+
return actResult;
|
|
67
|
+
}
|
|
68
|
+
} catch (error) {
|
|
69
|
+
// Can't be a `finally {}` block since we don't know if we have to immediately restore IS_REACT_ACT_ENVIRONMENT
|
|
70
|
+
// or if we have to await the callback first.
|
|
71
|
+
setIsReactActEnvironment(previousActEnvironment);
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const getAct = () => {
|
|
78
|
+
if (!_reactTestRenderer.act) {
|
|
79
|
+
return actMock;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return (0, _reactVersions.checkReactVersionAtLeast)(18, 0) ? withGlobalActEnvironment(_reactTestRenderer.act) : _reactTestRenderer.act;
|
|
83
|
+
};
|
|
15
84
|
|
|
85
|
+
const act = getAct();
|
|
86
|
+
var _default = act;
|
|
16
87
|
exports.default = _default;
|
|
17
88
|
//# sourceMappingURL=act.js.map
|
package/build/act.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"act.js","names":["actMock","callback","setIsReactActEnvironment","isReactActEnvironment","globalThis","IS_REACT_ACT_ENVIRONMENT","getIsReactActEnvironment","withGlobalActEnvironment","actImplementation","previousActEnvironment","callbackNeedsToBeAwaited","actResult","result","then","thenable","resolve","reject","returnValue","error","getAct","reactTestRendererAct","checkReactVersionAtLeast","act"],"sources":["../src/act.ts"],"sourcesContent":["// This file and the act() implementation is sourced from react-testing-library\n// https://github.com/testing-library/react-testing-library/blob/c80809a956b0b9f3289c4a6fa8b5e8cc72d6ef6d/src/act-compat.js\nimport { act as reactTestRendererAct } from 'react-test-renderer';\nimport { checkReactVersionAtLeast } from './react-versions';\n\nconst actMock = (callback: () => void) => {\n callback();\n};\n\n// See https://github.com/reactwg/react-18/discussions/102 for more context on global.IS_REACT_ACT_ENVIRONMENT\ndeclare global {\n var IS_REACT_ACT_ENVIRONMENT: boolean | undefined;\n}\n\nfunction setIsReactActEnvironment(isReactActEnvironment: boolean | undefined) {\n globalThis.IS_REACT_ACT_ENVIRONMENT = isReactActEnvironment;\n}\n\nfunction getIsReactActEnvironment() {\n return globalThis.IS_REACT_ACT_ENVIRONMENT;\n}\n\ntype Act = typeof reactTestRendererAct;\n\nfunction withGlobalActEnvironment(actImplementation: Act) {\n return (callback: Parameters<Act>[0]) => {\n const previousActEnvironment = getIsReactActEnvironment();\n setIsReactActEnvironment(true);\n\n // this code is riddled with eslint disabling comments because this doesn't use real promises but eslint thinks we do\n try {\n // The return value of `act` is always a thenable.\n let callbackNeedsToBeAwaited = false;\n const actResult = actImplementation(() => {\n const result = callback();\n if (\n result !== null &&\n typeof result === 'object' &&\n // @ts-expect-error this should be a promise or thenable\n // eslint-disable-next-line promise/prefer-await-to-then\n typeof result.then === 'function'\n ) {\n callbackNeedsToBeAwaited = true;\n }\n return result;\n });\n if (callbackNeedsToBeAwaited) {\n const thenable = actResult;\n return {\n then: (\n resolve: (value: never) => never,\n reject: (value: never) => never\n ) => {\n // eslint-disable-next-line\n thenable.then(\n // eslint-disable-next-line promise/always-return\n (returnValue) => {\n setIsReactActEnvironment(previousActEnvironment);\n resolve(returnValue);\n },\n (error) => {\n setIsReactActEnvironment(previousActEnvironment);\n reject(error);\n }\n );\n },\n };\n } else {\n setIsReactActEnvironment(previousActEnvironment);\n return actResult;\n }\n } catch (error) {\n // Can't be a `finally {}` block since we don't know if we have to immediately restore IS_REACT_ACT_ENVIRONMENT\n // or if we have to await the callback first.\n setIsReactActEnvironment(previousActEnvironment);\n throw error;\n }\n };\n}\nconst getAct = () => {\n if (!reactTestRendererAct) {\n return actMock;\n }\n\n return checkReactVersionAtLeast(18, 0)\n ? withGlobalActEnvironment(reactTestRendererAct)\n : reactTestRendererAct;\n};\nconst act = getAct();\n\nexport default act;\nexport {\n setIsReactActEnvironment as setReactActEnvironment,\n getIsReactActEnvironment,\n};\n"],"mappings":";;;;;;;;;AAEA;;AACA;;AAHA;AACA;AAIA,MAAMA,OAAO,GAAIC,QAAD,IAA0B;EACxCA,QAAQ;AACT,CAFD,C,CAIA;;;AAKA,SAASC,wBAAT,CAAkCC,qBAAlC,EAA8E;EAC5EC,UAAU,CAACC,wBAAX,GAAsCF,qBAAtC;AACD;;AAED,SAASG,wBAAT,GAAoC;EAClC,OAAOF,UAAU,CAACC,wBAAlB;AACD;;AAID,SAASE,wBAAT,CAAkCC,iBAAlC,EAA0D;EACxD,OAAQP,QAAD,IAAkC;IACvC,MAAMQ,sBAAsB,GAAGH,wBAAwB,EAAvD;IACAJ,wBAAwB,CAAC,IAAD,CAAxB,CAFuC,CAIvC;;IACA,IAAI;MACF;MACA,IAAIQ,wBAAwB,GAAG,KAA/B;MACA,MAAMC,SAAS,GAAGH,iBAAiB,CAAC,MAAM;QACxC,MAAMI,MAAM,GAAGX,QAAQ,EAAvB;;QACA,IACEW,MAAM,KAAK,IAAX,IACA,OAAOA,MAAP,KAAkB,QADlB,IAEA;QACA;QACA,OAAOA,MAAM,CAACC,IAAd,KAAuB,UALzB,EAME;UACAH,wBAAwB,GAAG,IAA3B;QACD;;QACD,OAAOE,MAAP;MACD,CAZkC,CAAnC;;MAaA,IAAIF,wBAAJ,EAA8B;QAC5B,MAAMI,QAAQ,GAAGH,SAAjB;QACA,OAAO;UACLE,IAAI,EAAE,CACJE,OADI,EAEJC,MAFI,KAGD;YACH;YACAF,QAAQ,CAACD,IAAT,EACE;YACCI,WAAD,IAAiB;cACff,wBAAwB,CAACO,sBAAD,CAAxB;cACAM,OAAO,CAACE,WAAD,CAAP;YACD,CALH,EAMGC,KAAD,IAAW;cACThB,wBAAwB,CAACO,sBAAD,CAAxB;cACAO,MAAM,CAACE,KAAD,CAAN;YACD,CATH;UAWD;QAjBI,CAAP;MAmBD,CArBD,MAqBO;QACLhB,wBAAwB,CAACO,sBAAD,CAAxB;QACA,OAAOE,SAAP;MACD;IACF,CAzCD,CAyCE,OAAOO,KAAP,EAAc;MACd;MACA;MACAhB,wBAAwB,CAACO,sBAAD,CAAxB;MACA,MAAMS,KAAN;IACD;EACF,CApDD;AAqDD;;AACD,MAAMC,MAAM,GAAG,MAAM;EACnB,IAAI,CAACC,sBAAL,EAA2B;IACzB,OAAOpB,OAAP;EACD;;EAED,OAAO,IAAAqB,uCAAA,EAAyB,EAAzB,EAA6B,CAA7B,IACHd,wBAAwB,CAACa,sBAAD,CADrB,GAEHA,sBAFJ;AAGD,CARD;;AASA,MAAME,GAAG,GAAGH,MAAM,EAAlB;eAEeG,G"}
|
package/build/cleanup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"cleanup.js","names":["cleanupQueue","Set","cleanup","clearRenderResult","forEach","fn","clear","addToCleanupQueue","add"],"sources":["../src/cleanup.ts"],"sourcesContent":["import * as React from 'react';\nimport { clearRenderResult } from './screen';\n\ntype CleanUpFunction = (nextElement?: React.ReactElement<any>) => void;\nlet cleanupQueue = new Set<CleanUpFunction>();\n\nexport default function cleanup() {\n clearRenderResult();\n cleanupQueue.forEach((fn) => fn());\n cleanupQueue.clear();\n}\n\nexport function addToCleanupQueue(fn: CleanUpFunction) {\n cleanupQueue.add(fn);\n}\n"],"mappings":";;;;;;;;AACA;;AAGA,IAAIA,YAAY,GAAG,IAAIC,GAAJ,EAAnB;;AAEe,SAASC,OAAT,GAAmB;EAChC,IAAAC,yBAAA;EACAH,YAAY,CAACI,OAAb,CAAsBC,EAAD,IAAQA,EAAE,EAA/B;EACAL,YAAY,CAACM,KAAb;AACD;;AAEM,SAASC,iBAAT,CAA2BF,EAA3B,EAAgD;EACrDL,YAAY,CAACQ,GAAb,CAAiBH,EAAjB;AACD"}
|
package/build/fireEvent.js
CHANGED
|
@@ -7,22 +7,32 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _act = _interopRequireDefault(require("./act"));
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
var _componentTree = require("./helpers/component-tree");
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
12
|
+
var _filterNodeByType = require("./helpers/filterNodeByType");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
16
|
const isTextInput = element => {
|
|
17
|
+
if (!element) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
const {
|
|
18
22
|
TextInput
|
|
19
|
-
} = require('react-native');
|
|
23
|
+
} = require('react-native'); // We have to test if the element type is either the TextInput component
|
|
24
|
+
// (which would if it is a composite component) or the string
|
|
25
|
+
// TextInput (which would be true if it is a host component)
|
|
26
|
+
// All queries but the one by testID return composite component and event
|
|
27
|
+
// if all queries returned host components, since fireEvent bubbles up
|
|
28
|
+
// it would trigger the parent prop without the composite component check
|
|
29
|
+
|
|
20
30
|
|
|
21
|
-
return element
|
|
31
|
+
return (0, _filterNodeByType.filterNodeByType)(element, TextInput) || (0, _filterNodeByType.filterNodeByType)(element, 'TextInput');
|
|
22
32
|
};
|
|
23
33
|
|
|
24
34
|
const isTouchResponder = element => {
|
|
25
|
-
if (!isHostElement(element)) return false;
|
|
35
|
+
if (!(0, _componentTree.isHostElement)(element)) return false;
|
|
26
36
|
return !!element?.props.onStartShouldSetResponder || isTextInput(element);
|
|
27
37
|
};
|
|
28
38
|
|
package/build/fireEvent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"fireEvent.js","names":["isTextInput","element","TextInput","require","filterNodeByType","isTouchResponder","isHostElement","props","onStartShouldSetResponder","isPointerEventEnabled","isParent","parentCondition","pointerEvents","parent","isTouchEvent","eventName","isEventEnabled","touchResponder","editable","touchStart","touchMove","onMoveShouldSetResponder","undefined","findEventHandler","callsite","nearestTouchResponder","handler","getEventHandler","eventHandlerName","toEventHandlerName","invokeEvent","data","returnValue","act","charAt","toUpperCase","slice","pressHandler","changeTextHandler","scrollHandler","fireEvent","press","changeText","scroll"],"sources":["../src/fireEvent.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport act from './act';\nimport { isHostElement } from './helpers/component-tree';\nimport { filterNodeByType } from './helpers/filterNodeByType';\n\ntype EventHandler = (...args: any) => unknown;\n\nconst isTextInput = (element?: ReactTestInstance) => {\n if (!element) {\n return false;\n }\n\n const { TextInput } = require('react-native');\n // We have to test if the element type is either the TextInput component\n // (which would if it is a composite component) or the string\n // TextInput (which would be true if it is a host component)\n // All queries but the one by testID return composite component and event\n // if all queries returned host components, since fireEvent bubbles up\n // it would trigger the parent prop without the composite component check\n return (\n filterNodeByType(element, TextInput) ||\n filterNodeByType(element, 'TextInput')\n );\n};\n\nconst isTouchResponder = (element?: ReactTestInstance) => {\n if (!isHostElement(element)) return false;\n\n return !!element?.props.onStartShouldSetResponder || isTextInput(element);\n};\n\nconst isPointerEventEnabled = (\n element?: ReactTestInstance,\n isParent?: boolean\n): boolean => {\n const parentCondition = isParent\n ? element?.props.pointerEvents === 'box-only'\n : element?.props.pointerEvents === 'box-none';\n\n if (element?.props.pointerEvents === 'none' || parentCondition) {\n return false;\n }\n\n if (!element?.parent) return true;\n\n return isPointerEventEnabled(element.parent, true);\n};\n\nconst isTouchEvent = (eventName?: string) => {\n return eventName === 'press';\n};\n\nconst isEventEnabled = (\n element?: ReactTestInstance,\n touchResponder?: ReactTestInstance,\n eventName?: string\n) => {\n if (isTextInput(element)) return element?.props.editable !== false;\n if (!isPointerEventEnabled(element) && isTouchEvent(eventName)) return false;\n\n const touchStart = touchResponder?.props.onStartShouldSetResponder?.();\n const touchMove = touchResponder?.props.onMoveShouldSetResponder?.();\n\n if (touchStart || touchMove) return true;\n\n return touchStart === undefined && touchMove === undefined;\n};\n\nconst findEventHandler = (\n element: ReactTestInstance,\n eventName: string,\n callsite?: any,\n nearestTouchResponder?: ReactTestInstance\n): EventHandler | null => {\n const touchResponder = isTouchResponder(element)\n ? element\n : nearestTouchResponder;\n\n const handler = getEventHandler(element, eventName);\n if (handler && isEventEnabled(element, touchResponder, eventName))\n return handler;\n\n if (element.parent === null || element.parent.parent === null) {\n return null;\n }\n\n return findEventHandler(element.parent, eventName, callsite, touchResponder);\n};\n\nconst getEventHandler = (\n element: ReactTestInstance,\n eventName: string\n): EventHandler | undefined => {\n const eventHandlerName = toEventHandlerName(eventName);\n if (typeof element.props[eventHandlerName] === 'function') {\n return element.props[eventHandlerName];\n }\n\n if (typeof element.props[eventName] === 'function') {\n return element.props[eventName];\n }\n\n return undefined;\n};\n\nconst invokeEvent = (\n element: ReactTestInstance,\n eventName: string,\n callsite?: any,\n ...data: Array<any>\n) => {\n const handler = findEventHandler(element, eventName, callsite);\n\n if (!handler) {\n return;\n }\n\n let returnValue;\n\n act(() => {\n returnValue = handler(...data);\n });\n\n return returnValue;\n};\n\nconst toEventHandlerName = (eventName: string) =>\n `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;\n\nconst pressHandler = (element: ReactTestInstance, ...data: Array<any>): void =>\n invokeEvent(element, 'press', pressHandler, ...data);\nconst changeTextHandler = (\n element: ReactTestInstance,\n ...data: Array<any>\n): void => invokeEvent(element, 'changeText', changeTextHandler, ...data);\nconst scrollHandler = (element: ReactTestInstance, ...data: Array<any>): void =>\n invokeEvent(element, 'scroll', scrollHandler, ...data);\n\nconst fireEvent = (\n element: ReactTestInstance,\n eventName: string,\n ...data: Array<any>\n): void => invokeEvent(element, eventName, fireEvent, ...data);\n\nfireEvent.press = pressHandler;\nfireEvent.changeText = changeTextHandler;\nfireEvent.scroll = scrollHandler;\n\nexport default fireEvent;\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;;;AAIA,MAAMA,WAAW,GAAIC,OAAD,IAAiC;EACnD,IAAI,CAACA,OAAL,EAAc;IACZ,OAAO,KAAP;EACD;;EAED,MAAM;IAAEC;EAAF,IAAgBC,OAAO,CAAC,cAAD,CAA7B,CALmD,CAMnD;EACA;EACA;EACA;EACA;EACA;;;EACA,OACE,IAAAC,kCAAA,EAAiBH,OAAjB,EAA0BC,SAA1B,KACA,IAAAE,kCAAA,EAAiBH,OAAjB,EAA0B,WAA1B,CAFF;AAID,CAhBD;;AAkBA,MAAMI,gBAAgB,GAAIJ,OAAD,IAAiC;EACxD,IAAI,CAAC,IAAAK,4BAAA,EAAcL,OAAd,CAAL,EAA6B,OAAO,KAAP;EAE7B,OAAO,CAAC,CAACA,OAAO,EAAEM,KAAT,CAAeC,yBAAjB,IAA8CR,WAAW,CAACC,OAAD,CAAhE;AACD,CAJD;;AAMA,MAAMQ,qBAAqB,GAAG,CAC5BR,OAD4B,EAE5BS,QAF4B,KAGhB;EACZ,MAAMC,eAAe,GAAGD,QAAQ,GAC5BT,OAAO,EAAEM,KAAT,CAAeK,aAAf,KAAiC,UADL,GAE5BX,OAAO,EAAEM,KAAT,CAAeK,aAAf,KAAiC,UAFrC;;EAIA,IAAIX,OAAO,EAAEM,KAAT,CAAeK,aAAf,KAAiC,MAAjC,IAA2CD,eAA/C,EAAgE;IAC9D,OAAO,KAAP;EACD;;EAED,IAAI,CAACV,OAAO,EAAEY,MAAd,EAAsB,OAAO,IAAP;EAEtB,OAAOJ,qBAAqB,CAACR,OAAO,CAACY,MAAT,EAA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,EAAwBqC,iBAAxB,EAA2C,GAAGP,IAA9C,CAHtB;;AAIA,MAAMQ,aAAa,GAAG,CAACtC,OAAD,EAA6B,GAAG8B,IAAhC,KACpBD,WAAW,CAAC7B,OAAD,EAAU,QAAV,EAAoBsC,aAApB,EAAmC,GAAGR,IAAtC,CADb;;AAGA,MAAMS,SAAS,GAAG,CAChBvC,OADgB,EAEhBc,SAFgB,EAGhB,GAAGgB,IAHa,KAIPD,WAAW,CAAC7B,OAAD,EAAUc,SAAV,EAAqByB,SAArB,EAAgC,GAAGT,IAAnC,CAJtB;;AAMAS,SAAS,CAACC,KAAV,GAAkBJ,YAAlB;AACAG,SAAS,CAACE,UAAV,GAAuBJ,iBAAvB;AACAE,SAAS,CAACG,MAAV,GAAmBJ,aAAnB;eAEeC,S"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"flushMicroTasks.js","names":["flushMicroTasks","then","resolve","setImmediate"],"sources":["../src/flushMicroTasks.ts"],"sourcesContent":["import { setImmediate } from './helpers/timers';\n\ntype Thenable<T> = { then: (callback: () => T) => unknown };\n\nexport function flushMicroTasks<T>(): Thenable<T> {\n return {\n // using \"thenable\" instead of a Promise, because otherwise it breaks when\n // using \"modern\" fake timers\n then(resolve) {\n setImmediate(resolve);\n },\n };\n}\n"],"mappings":";;;;;;;AAAA;;AAIO,SAASA,eAAT,GAA2C;EAChD,OAAO;IACL;IACA;IACAC,IAAI,CAACC,OAAD,EAAU;MACZ,IAAAC,oBAAA,EAAaD,OAAb;IACD;;EALI,CAAP;AAOD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isInaccessible = isInaccessible;
|
|
7
|
+
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
|
|
10
|
+
var _componentTree = require("./component-tree");
|
|
11
|
+
|
|
12
|
+
function isInaccessible(element) {
|
|
13
|
+
if (element == null) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let current = element;
|
|
18
|
+
|
|
19
|
+
while (current) {
|
|
20
|
+
if (isSubtreeInaccessible(current)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
current = current.parent;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function isSubtreeInaccessible(element) {
|
|
31
|
+
if (element == null) {
|
|
32
|
+
return true;
|
|
33
|
+
} // iOS: accessibilityElementsHidden
|
|
34
|
+
// See: https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
if (element.props.accessibilityElementsHidden) {
|
|
38
|
+
return true;
|
|
39
|
+
} // Android: importantForAccessibility
|
|
40
|
+
// See: https://reactnative.dev/docs/accessibility#importantforaccessibility-android
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
if (element.props.importantForAccessibility === 'no-hide-descendants') {
|
|
44
|
+
return true;
|
|
45
|
+
} // Note that `opacity: 0` is not threated as inassessible on iOS
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
const flatStyle = _reactNative.StyleSheet.flatten(element.props.style) ?? {};
|
|
49
|
+
if (flatStyle.display === 'none') return true; // iOS: accessibilityViewIsModal
|
|
50
|
+
// See: https://reactnative.dev/docs/accessibility#accessibilityviewismodal-ios
|
|
51
|
+
|
|
52
|
+
const hostSiblings = (0, _componentTree.getHostSiblings)(element);
|
|
53
|
+
|
|
54
|
+
if (hostSiblings.some(sibling => sibling.props.accessibilityViewIsModal)) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=accessiblity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessiblity.js","names":["isInaccessible","element","current","isSubtreeInaccessible","parent","props","accessibilityElementsHidden","importantForAccessibility","flatStyle","StyleSheet","flatten","style","display","hostSiblings","getHostSiblings","some","sibling","accessibilityViewIsModal"],"sources":["../../src/helpers/accessiblity.ts"],"sourcesContent":["import { StyleSheet } from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { getHostSiblings } from './component-tree';\n\nexport function isInaccessible(element: ReactTestInstance | null): boolean {\n if (element == null) {\n return true;\n }\n\n let current: ReactTestInstance | null = element;\n while (current) {\n if (isSubtreeInaccessible(current)) {\n return true;\n }\n\n current = current.parent;\n }\n\n return false;\n}\n\nfunction isSubtreeInaccessible(element: ReactTestInstance | null): boolean {\n if (element == null) {\n return true;\n }\n\n // iOS: accessibilityElementsHidden\n // See: https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios\n if (element.props.accessibilityElementsHidden) {\n return true;\n }\n\n // Android: importantForAccessibility\n // See: https://reactnative.dev/docs/accessibility#importantforaccessibility-android\n if (element.props.importantForAccessibility === 'no-hide-descendants') {\n return true;\n }\n\n // Note that `opacity: 0` is not threated as inassessible on iOS\n const flatStyle = StyleSheet.flatten(element.props.style) ?? {};\n if (flatStyle.display === 'none') return true;\n\n // iOS: accessibilityViewIsModal\n // See: https://reactnative.dev/docs/accessibility#accessibilityviewismodal-ios\n const hostSiblings = getHostSiblings(element);\n if (hostSiblings.some((sibling) => sibling.props.accessibilityViewIsModal)) {\n return true;\n }\n\n return false;\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEO,SAASA,cAAT,CAAwBC,OAAxB,EAAoE;EACzE,IAAIA,OAAO,IAAI,IAAf,EAAqB;IACnB,OAAO,IAAP;EACD;;EAED,IAAIC,OAAiC,GAAGD,OAAxC;;EACA,OAAOC,OAAP,EAAgB;IACd,IAAIC,qBAAqB,CAACD,OAAD,CAAzB,EAAoC;MAClC,OAAO,IAAP;IACD;;IAEDA,OAAO,GAAGA,OAAO,CAACE,MAAlB;EACD;;EAED,OAAO,KAAP;AACD;;AAED,SAASD,qBAAT,CAA+BF,OAA/B,EAA2E;EACzE,IAAIA,OAAO,IAAI,IAAf,EAAqB;IACnB,OAAO,IAAP;EACD,CAHwE,CAKzE;EACA;;;EACA,IAAIA,OAAO,CAACI,KAAR,CAAcC,2BAAlB,EAA+C;IAC7C,OAAO,IAAP;EACD,CATwE,CAWzE;EACA;;;EACA,IAAIL,OAAO,CAACI,KAAR,CAAcE,yBAAd,KAA4C,qBAAhD,EAAuE;IACrE,OAAO,IAAP;EACD,CAfwE,CAiBzE;;;EACA,MAAMC,SAAS,GAAGC,uBAAA,CAAWC,OAAX,CAAmBT,OAAO,CAACI,KAAR,CAAcM,KAAjC,KAA2C,EAA7D;EACA,IAAIH,SAAS,CAACI,OAAV,KAAsB,MAA1B,EAAkC,OAAO,IAAP,CAnBuC,CAqBzE;EACA;;EACA,MAAMC,YAAY,GAAG,IAAAC,8BAAA,EAAgBb,OAAhB,CAArB;;EACA,IAAIY,YAAY,CAACE,IAAb,CAAmBC,OAAD,IAAaA,OAAO,CAACX,KAAR,CAAcY,wBAA7C,CAAJ,EAA4E;IAC1E,OAAO,IAAP;EACD;;EAED,OAAO,KAAP;AACD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given element is a host element.
|
|
4
|
+
* @param element The element to check.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isHostElement(element?: ReactTestInstance | null): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Returns first host ancestor for given element.
|
|
9
|
+
* @param element The element start traversing from.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getHostParent(element: ReactTestInstance | null): ReactTestInstance | null;
|
|
12
|
+
/**
|
|
13
|
+
* Returns host children for given element.
|
|
14
|
+
* @param element The element start traversing from.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getHostChildren(element: ReactTestInstance | null): ReactTestInstance[];
|
|
17
|
+
/**
|
|
18
|
+
* Return the array of host elements that represent the passed element.
|
|
19
|
+
*
|
|
20
|
+
* @param element The element start traversing from.
|
|
21
|
+
* @returns If the passed element is a host element, it will return an array containing only that element,
|
|
22
|
+
* if the passed element is a composite element, it will return an array containing its host children (zero, one or many).
|
|
23
|
+
*/
|
|
24
|
+
export declare function getHostSelves(element: ReactTestInstance | null): ReactTestInstance[];
|
|
25
|
+
/**
|
|
26
|
+
* Returns host siblings for given element.
|
|
27
|
+
* @param element The element start traversing from.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getHostSiblings(element: ReactTestInstance | null): ReactTestInstance[];
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getHostChildren = getHostChildren;
|
|
7
|
+
exports.getHostParent = getHostParent;
|
|
8
|
+
exports.getHostSelves = getHostSelves;
|
|
9
|
+
exports.getHostSiblings = getHostSiblings;
|
|
10
|
+
exports.isHostElement = isHostElement;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Checks if the given element is a host element.
|
|
14
|
+
* @param element The element to check.
|
|
15
|
+
*/
|
|
16
|
+
function isHostElement(element) {
|
|
17
|
+
return typeof element?.type === 'string';
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns first host ancestor for given element.
|
|
21
|
+
* @param element The element start traversing from.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
function getHostParent(element) {
|
|
26
|
+
if (element == null) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let current = element.parent;
|
|
31
|
+
|
|
32
|
+
while (current) {
|
|
33
|
+
if (isHostElement(current)) {
|
|
34
|
+
return current;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
current = current.parent;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns host children for given element.
|
|
44
|
+
* @param element The element start traversing from.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
function getHostChildren(element) {
|
|
49
|
+
if (element == null) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const hostChildren = [];
|
|
54
|
+
element.children.forEach(child => {
|
|
55
|
+
if (typeof child !== 'object') {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (isHostElement(child)) {
|
|
60
|
+
hostChildren.push(child);
|
|
61
|
+
} else {
|
|
62
|
+
hostChildren.push(...getHostChildren(child));
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return hostChildren;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Return the array of host elements that represent the passed element.
|
|
69
|
+
*
|
|
70
|
+
* @param element The element start traversing from.
|
|
71
|
+
* @returns If the passed element is a host element, it will return an array containing only that element,
|
|
72
|
+
* if the passed element is a composite element, it will return an array containing its host children (zero, one or many).
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
function getHostSelves(element) {
|
|
77
|
+
return typeof element?.type === 'string' ? [element] : getHostChildren(element);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Returns host siblings for given element.
|
|
81
|
+
* @param element The element start traversing from.
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
function getHostSiblings(element) {
|
|
86
|
+
const hostParent = getHostParent(element);
|
|
87
|
+
const hostSelves = getHostSelves(element);
|
|
88
|
+
return getHostChildren(hostParent).filter(sibling => !hostSelves.includes(sibling));
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=component-tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-tree.js","names":["isHostElement","element","type","getHostParent","current","parent","getHostChildren","hostChildren","children","forEach","child","push","getHostSelves","getHostSiblings","hostParent","hostSelves","filter","sibling","includes"],"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 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"],"mappings":";;;;;;;;;;;AAEA;AACA;AACA;AACA;AACO,SAASA,aAAT,CAAuBC,OAAvB,EAAoE;EACzE,OAAO,OAAOA,OAAO,EAAEC,IAA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C,OAAD,IAAa,CAACF,UAAU,CAACG,QAAX,CAAoBD,OAApB,CADT,CAAP;AAGD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
|
@@ -2,8 +2,8 @@ export declare class ErrorWithStack extends Error {
|
|
|
2
2
|
constructor(message: string | undefined, callsite: Function);
|
|
3
3
|
}
|
|
4
4
|
export declare const createLibraryNotSupportedError: (error: unknown) => Error;
|
|
5
|
-
export declare const prepareErrorMessage: (error: unknown, name?: string
|
|
6
|
-
export declare const createQueryByError: (error:
|
|
5
|
+
export declare const prepareErrorMessage: (error: unknown, name?: string, value?: unknown) => string;
|
|
6
|
+
export declare const createQueryByError: (error: unknown, callsite: Function) => null;
|
|
7
7
|
export declare function copyStackTrace(target: unknown, stackTraceSource: Error): void;
|
|
8
8
|
export declare function printDeprecationWarning(functionName: string): void;
|
|
9
9
|
export declare function throwRemovedFunctionError(functionName: string, docsRef: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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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
2
|
import * as React from 'react';
|
|
3
|
-
export declare const filterNodeByType: (node: ReactTestInstance | React.ReactElement, type: React.ElementType) => boolean;
|
|
3
|
+
export declare const filterNodeByType: (node: ReactTestInstance | React.ReactElement, type: React.ElementType | string) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.validateStringsRenderedWithinText = void 0;
|
|
7
|
+
|
|
8
|
+
const validateStringsRenderedWithinText = rendererJSON => {
|
|
9
|
+
if (!rendererJSON) return;
|
|
10
|
+
|
|
11
|
+
if (Array.isArray(rendererJSON)) {
|
|
12
|
+
rendererJSON.forEach(validateStringsRenderedWithinTextForNode);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return validateStringsRenderedWithinTextForNode(rendererJSON);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.validateStringsRenderedWithinText = validateStringsRenderedWithinText;
|
|
20
|
+
|
|
21
|
+
const validateStringsRenderedWithinTextForNode = node => {
|
|
22
|
+
if (typeof node === 'string') {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (node.type !== 'Text') {
|
|
27
|
+
node.children?.forEach(child => {
|
|
28
|
+
if (typeof child === 'string') {
|
|
29
|
+
throw new Error(`Invariant Violation: Text strings must be rendered within a <Text> component. Detected attempt to render "${child}" string within a <${node.type}> component.`);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (node.children) {
|
|
35
|
+
node.children.forEach(validateStringsRenderedWithinTextForNode);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=stringValidation.js.map
|
|
@@ -0,0 +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"}
|