@testing-library/react-native 11.4.0 → 11.5.1
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 +3 -3
- package/build/act.d.ts +3 -1
- package/build/act.js +1 -13
- package/build/act.js.map +1 -1
- package/build/cleanup.d.ts +1 -1
- package/build/config.d.ts +31 -2
- package/build/config.js +28 -3
- package/build/config.js.map +1 -1
- package/build/fireEvent.js +3 -3
- package/build/fireEvent.js.map +1 -1
- package/build/flushMicroTasks.d.ts +1 -1
- package/build/helpers/accessiblity.d.ts +11 -4
- package/build/helpers/accessiblity.js +29 -9
- package/build/helpers/accessiblity.js.map +1 -1
- package/build/helpers/debugDeep.d.ts +1 -1
- package/build/helpers/findAll.d.ts +10 -0
- package/build/helpers/findAll.js +44 -0
- package/build/helpers/findAll.js.map +1 -0
- package/build/helpers/format.d.ts +2 -2
- package/build/helpers/getTextContent.d.ts +2 -0
- package/build/helpers/getTextContent.js +20 -0
- package/build/helpers/getTextContent.js.map +1 -0
- package/build/helpers/host-component-names.d.ts +2 -0
- package/build/helpers/host-component-names.js +50 -0
- package/build/helpers/host-component-names.js.map +1 -0
- package/build/helpers/matchers/accessibilityValue.d.ts +9 -0
- package/build/helpers/matchers/accessibilityValue.js +12 -0
- package/build/helpers/matchers/accessibilityValue.js.map +1 -0
- package/build/helpers/matchers/matchLabelText.d.ts +3 -0
- package/build/helpers/matchers/matchLabelText.js +26 -0
- package/build/helpers/matchers/matchLabelText.js.map +1 -0
- package/build/helpers/matchers/matchTextContent.d.ts +10 -0
- package/build/helpers/matchers/matchTextContent.js +24 -0
- package/build/helpers/matchers/matchTextContent.js.map +1 -0
- package/build/helpers/timers.d.ts +0 -2
- package/build/helpers/timers.js.map +1 -1
- package/build/index.flow.js +123 -54
- package/build/matches.d.ts +7 -3
- package/build/matches.js.map +1 -1
- package/build/pure.d.ts +12 -23
- package/build/pure.js +8 -2
- package/build/pure.js.map +1 -1
- package/build/queries/a11yState.d.ts +15 -14
- package/build/queries/a11yState.js +3 -2
- package/build/queries/a11yState.js.map +1 -1
- package/build/queries/a11yValue.d.ts +15 -20
- package/build/queries/a11yValue.js +16 -5
- package/build/queries/a11yValue.js.map +1 -1
- package/build/queries/displayValue.d.ts +11 -9
- package/build/queries/displayValue.js +7 -2
- package/build/queries/displayValue.js.map +1 -1
- package/build/queries/hintText.d.ts +23 -21
- package/build/queries/hintText.js +2 -1
- package/build/queries/hintText.js.map +1 -1
- package/build/queries/labelText.d.ts +11 -9
- package/build/queries/labelText.js +7 -11
- package/build/queries/labelText.js.map +1 -1
- package/build/queries/makeQueries.d.ts +8 -8
- package/build/queries/options.d.ts +11 -0
- package/build/queries/options.js +2 -0
- package/build/queries/options.js.map +1 -0
- package/build/queries/placeholderText.d.ts +11 -9
- package/build/queries/placeholderText.js +8 -3
- package/build/queries/placeholderText.js.map +1 -1
- package/build/queries/role.d.ts +7 -4
- package/build/queries/role.js +22 -11
- package/build/queries/role.js.map +1 -1
- package/build/queries/testId.d.ts +11 -9
- package/build/queries/testId.js +2 -2
- package/build/queries/testId.js.map +1 -1
- package/build/queries/text.d.ts +11 -13
- package/build/queries/text.js +24 -51
- package/build/queries/text.js.map +1 -1
- package/build/queries/unsafeProps.d.ts +1 -1
- package/build/queries/unsafeType.d.ts +1 -1
- package/build/render.d.ts +92 -146
- package/build/renderHook.d.ts +2 -2
- package/build/waitFor.d.ts +1 -1
- package/build/within.d.ts +90 -144
- package/package.json +17 -18
- package/typings/index.flow.js +123 -54
package/README.md
CHANGED
|
@@ -117,8 +117,8 @@ test('form submits two answers', () => {
|
|
|
117
117
|
fireEvent.press(screen.getByText('Submit'));
|
|
118
118
|
|
|
119
119
|
expect(mockFn).toBeCalledWith({
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
1: { q: 'q1', a: 'a1' },
|
|
121
|
+
2: { q: 'q2', a: 'a2' },
|
|
122
122
|
});
|
|
123
123
|
});
|
|
124
124
|
```
|
|
@@ -173,4 +173,4 @@ Supported and used by [Rally Health](https://www.rallyhealth.com/careers-home).
|
|
|
173
173
|
[callstack-badge]: https://callstack.com/images/callstack-badge.svg
|
|
174
174
|
[callstack]: https://callstack.com/open-source/?utm_source=github.com&utm_medium=referral&utm_campaign=react-native-testing-library&utm_term=readme
|
|
175
175
|
[codecov-badge]: https://codecov.io/gh/callstack/react-native-testing-library/branch/main/graph/badge.svg?token=tYVSWro1IP
|
|
176
|
-
[codecov]: https://codecov.io/gh/callstack/react-native-testing-library
|
|
176
|
+
[codecov]: https://codecov.io/gh/callstack/react-native-testing-library
|
package/build/act.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { act as reactTestRendererAct } from 'react-test-renderer';
|
|
2
|
+
type ReactAct = typeof reactTestRendererAct;
|
|
1
3
|
declare global {
|
|
2
4
|
var IS_REACT_ACT_ENVIRONMENT: boolean | undefined;
|
|
3
5
|
}
|
|
4
6
|
declare function setIsReactActEnvironment(isReactActEnvironment: boolean | undefined): void;
|
|
5
7
|
declare function getIsReactActEnvironment(): boolean | undefined;
|
|
6
|
-
declare const act:
|
|
8
|
+
declare const act: ReactAct;
|
|
7
9
|
export default act;
|
|
8
10
|
export { setIsReactActEnvironment as setReactActEnvironment, getIsReactActEnvironment, };
|
package/build/act.js
CHANGED
|
@@ -11,12 +11,6 @@ var _reactVersions = require("./react-versions");
|
|
|
11
11
|
// This file and the act() implementation is sourced from react-testing-library
|
|
12
12
|
// https://github.com/testing-library/react-testing-library/blob/c80809a956b0b9f3289c4a6fa8b5e8cc72d6ef6d/src/act-compat.js
|
|
13
13
|
|
|
14
|
-
const actMock = callback => {
|
|
15
|
-
callback();
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// See https://github.com/reactwg/react-18/discussions/102 for more context on global.IS_REACT_ACT_ENVIRONMENT
|
|
19
|
-
|
|
20
14
|
function setIsReactActEnvironment(isReactActEnvironment) {
|
|
21
15
|
globalThis.IS_REACT_ACT_ENVIRONMENT = isReactActEnvironment;
|
|
22
16
|
}
|
|
@@ -70,13 +64,7 @@ function withGlobalActEnvironment(actImplementation) {
|
|
|
70
64
|
}
|
|
71
65
|
};
|
|
72
66
|
}
|
|
73
|
-
const
|
|
74
|
-
if (!_reactTestRenderer.act) {
|
|
75
|
-
return actMock;
|
|
76
|
-
}
|
|
77
|
-
return (0, _reactVersions.checkReactVersionAtLeast)(18, 0) ? withGlobalActEnvironment(_reactTestRenderer.act) : _reactTestRenderer.act;
|
|
78
|
-
};
|
|
79
|
-
const act = getAct();
|
|
67
|
+
const act = (0, _reactVersions.checkReactVersionAtLeast)(18, 0) ? withGlobalActEnvironment(_reactTestRenderer.act) : _reactTestRenderer.act;
|
|
80
68
|
var _default = act;
|
|
81
69
|
exports.default = _default;
|
|
82
70
|
//# sourceMappingURL=act.js.map
|
package/build/act.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"act.js","names":["
|
|
1
|
+
{"version":3,"file":"act.js","names":["setIsReactActEnvironment","isReactActEnvironment","globalThis","IS_REACT_ACT_ENVIRONMENT","getIsReactActEnvironment","withGlobalActEnvironment","actImplementation","callback","previousActEnvironment","callbackNeedsToBeAwaited","actResult","result","then","thenable","resolve","reject","returnValue","error","act","checkReactVersionAtLeast","reactTestRendererAct"],"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\ntype ReactAct = typeof reactTestRendererAct;\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\nfunction withGlobalActEnvironment(actImplementation: ReactAct) {\n return (callback: Parameters<ReactAct>[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\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}\n\nconst act: ReactAct = checkReactVersionAtLeast(18, 0)\n ? (withGlobalActEnvironment(reactTestRendererAct) as ReactAct)\n : reactTestRendererAct;\n\nexport default act;\nexport {\n setIsReactActEnvironment as setReactActEnvironment,\n getIsReactActEnvironment,\n};\n"],"mappings":";;;;;;;;AAEA;AACA;AAHA;AACA;;AAWA,SAASA,wBAAwB,CAACC,qBAA0C,EAAE;EAC5EC,UAAU,CAACC,wBAAwB,GAAGF,qBAAqB;AAC7D;AAEA,SAASG,wBAAwB,GAAG;EAClC,OAAOF,UAAU,CAACC,w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|
package/build/cleanup.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
type CleanUpFunction = (nextElement?: React.ReactElement<any>) => void;
|
|
3
3
|
export default function cleanup(): void;
|
|
4
4
|
export declare function addToCleanupQueue(fn: CleanUpFunction): void;
|
|
5
5
|
export {};
|
package/build/config.d.ts
CHANGED
|
@@ -1,15 +1,44 @@
|
|
|
1
1
|
import { DebugOptions } from './helpers/debugDeep';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Global configuration options for React Native Testing Library.
|
|
4
|
+
*/
|
|
5
|
+
export type Config = {
|
|
3
6
|
/** Default timeout, in ms, for `waitFor` and `findBy*` queries. */
|
|
4
7
|
asyncUtilTimeout: number;
|
|
8
|
+
/** Default value for `includeHiddenElements` query option. */
|
|
9
|
+
defaultIncludeHiddenElements: boolean;
|
|
5
10
|
/** Default options for `debug` helper. */
|
|
6
11
|
defaultDebugOptions?: Partial<DebugOptions>;
|
|
7
12
|
};
|
|
8
|
-
export
|
|
13
|
+
export type ConfigAliasOptions = {
|
|
14
|
+
/** RTL-compatibility alias to `defaultIncludeHiddenElements` */
|
|
15
|
+
defaultHidden: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type HostComponentNames = {
|
|
18
|
+
text: string;
|
|
19
|
+
textInput: string;
|
|
20
|
+
};
|
|
21
|
+
export type InternalConfig = Config & {
|
|
22
|
+
/** Whether to use breaking changes intended for next major version release. */
|
|
23
|
+
useBreakingChanges: boolean;
|
|
24
|
+
/** Names for key React Native host components. */
|
|
25
|
+
hostComponentNames?: HostComponentNames;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Configure global options for React Native Testing Library.
|
|
29
|
+
*/
|
|
30
|
+
export declare function configure(options: Partial<Config & ConfigAliasOptions>): void;
|
|
31
|
+
export declare function configureInternal(option: Partial<InternalConfig>): void;
|
|
9
32
|
export declare function resetToDefaults(): void;
|
|
10
33
|
export declare function getConfig(): {
|
|
11
34
|
/** Default timeout, in ms, for `waitFor` and `findBy*` queries. */
|
|
12
35
|
asyncUtilTimeout: number;
|
|
36
|
+
/** Default value for `includeHiddenElements` query option. */
|
|
37
|
+
defaultIncludeHiddenElements: boolean;
|
|
13
38
|
/** Default options for `debug` helper. */
|
|
14
39
|
defaultDebugOptions?: Partial<DebugOptions> | undefined;
|
|
40
|
+
/** Whether to use breaking changes intended for next major version release. */
|
|
41
|
+
useBreakingChanges: boolean;
|
|
42
|
+
/** Names for key React Native host components. */
|
|
43
|
+
hostComponentNames?: HostComponentNames | undefined;
|
|
15
44
|
};
|
package/build/config.js
CHANGED
|
@@ -4,22 +4,47 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.configure = configure;
|
|
7
|
+
exports.configureInternal = configureInternal;
|
|
7
8
|
exports.getConfig = getConfig;
|
|
8
9
|
exports.resetToDefaults = resetToDefaults;
|
|
10
|
+
/**
|
|
11
|
+
* Global configuration options for React Native Testing Library.
|
|
12
|
+
*/
|
|
13
|
+
|
|
9
14
|
const defaultConfig = {
|
|
10
|
-
|
|
15
|
+
useBreakingChanges: false,
|
|
16
|
+
asyncUtilTimeout: 1000,
|
|
17
|
+
defaultIncludeHiddenElements: true
|
|
11
18
|
};
|
|
12
19
|
let config = {
|
|
13
20
|
...defaultConfig
|
|
14
21
|
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Configure global options for React Native Testing Library.
|
|
25
|
+
*/
|
|
15
26
|
function configure(options) {
|
|
27
|
+
const {
|
|
28
|
+
defaultHidden,
|
|
29
|
+
...restOptions
|
|
30
|
+
} = options;
|
|
31
|
+
const defaultIncludeHiddenElements = restOptions.defaultIncludeHiddenElements ?? defaultHidden ?? config.defaultIncludeHiddenElements;
|
|
32
|
+
config = {
|
|
33
|
+
...config,
|
|
34
|
+
...restOptions,
|
|
35
|
+
defaultIncludeHiddenElements
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function configureInternal(option) {
|
|
16
39
|
config = {
|
|
17
40
|
...config,
|
|
18
|
-
...
|
|
41
|
+
...option
|
|
19
42
|
};
|
|
20
43
|
}
|
|
21
44
|
function resetToDefaults() {
|
|
22
|
-
config =
|
|
45
|
+
config = {
|
|
46
|
+
...defaultConfig
|
|
47
|
+
};
|
|
23
48
|
}
|
|
24
49
|
function getConfig() {
|
|
25
50
|
return config;
|
package/build/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["defaultConfig","asyncUtilTimeout","config","configure","options","resetToDefaults","getConfig"],"sources":["../src/config.ts"],"sourcesContent":["import { DebugOptions } from './helpers/debugDeep';\n\nexport type Config = {\n /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */\n asyncUtilTimeout: number;\n\n /** Default options for `debug` helper. */\n defaultDebugOptions?: Partial<DebugOptions>;\n};\n\nconst defaultConfig:
|
|
1
|
+
{"version":3,"file":"config.js","names":["defaultConfig","useBreakingChanges","asyncUtilTimeout","defaultIncludeHiddenElements","config","configure","options","defaultHidden","restOptions","configureInternal","option","resetToDefaults","getConfig"],"sources":["../src/config.ts"],"sourcesContent":["import { DebugOptions } from './helpers/debugDeep';\n\n/**\n * Global configuration options for React Native Testing Library.\n */\n\nexport type Config = {\n /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */\n asyncUtilTimeout: number;\n\n /** Default value for `includeHiddenElements` query option. */\n defaultIncludeHiddenElements: boolean;\n\n /** Default options for `debug` helper. */\n defaultDebugOptions?: Partial<DebugOptions>;\n};\n\nexport type ConfigAliasOptions = {\n /** RTL-compatibility alias to `defaultIncludeHiddenElements` */\n defaultHidden: boolean;\n};\n\nexport type HostComponentNames = {\n text: string;\n textInput: string;\n};\n\nexport type InternalConfig = Config & {\n /** Whether to use breaking changes intended for next major version release. */\n useBreakingChanges: boolean;\n\n /** Names for key React Native host components. */\n hostComponentNames?: HostComponentNames;\n};\n\nconst defaultConfig: InternalConfig = {\n useBreakingChanges: false,\n asyncUtilTimeout: 1000,\n defaultIncludeHiddenElements: true,\n};\n\nlet config = { ...defaultConfig };\n\n/**\n * Configure global options for React Native Testing Library.\n */\nexport function configure(options: Partial<Config & ConfigAliasOptions>) {\n const { defaultHidden, ...restOptions } = options;\n\n const defaultIncludeHiddenElements =\n restOptions.defaultIncludeHiddenElements ??\n defaultHidden ??\n config.defaultIncludeHiddenElements;\n\n config = {\n ...config,\n ...restOptions,\n defaultIncludeHiddenElements,\n };\n}\n\nexport function configureInternal(option: Partial<InternalConfig>) {\n config = {\n ...config,\n ...option,\n };\n}\n\nexport function resetToDefaults() {\n config = { ...defaultConfig };\n}\n\nexport function getConfig() {\n return config;\n}\n"],"mappings":";;;;;;;;;AAEA;AACA;AACA;;AA+BA,MAAMA,aAA6B,GAAG;EACpCC,kBAAkB,EAAE,KAAK;EACzBC,gBAAgB,EAAE,IAAI;EACtBC,4BAA4B,EAAE;AAChC,CAAC;AAED,IAAIC,MAAM,GAAG;EAAE,GAAGJ;AAAc,CAAC;;AAEjC;AACA;AACA;AACO,SAASK,SAAS,CAACC,OAA6C,EAAE;EACvE,MAAM;IAAEC,aAAa;IAAE,GAAGC;EAAY,CAAC,GAAGF,OAAO;EAEjD,MAAMH,4BAA4B,GAChCK,WAAW,CAACL,4BAA4B,IACxCI,aAAa,IACbH,MAAM,CAACD,4BAA4B;EAErCC,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGI,WAAW;IACdL;EACF,CAAC;AACH;AAEO,SAASM,iBAAiB,CAACC,MAA+B,EAAE;EACjEN,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGM;EACL,CAAC;AACH;AAEO,SAASC,eAAe,GAAG;EAChCP,MAAM,GAAG;IAAE,GAAGJ;EAAc,CAAC;AAC/B;AAEO,SAASY,SAAS,GAAG;EAC1B,OAAOR,MAAM;AACf"}
|
package/build/fireEvent.js
CHANGED
|
@@ -8,6 +8,7 @@ var _reactNative = require("react-native");
|
|
|
8
8
|
var _act = _interopRequireDefault(require("./act"));
|
|
9
9
|
var _componentTree = require("./helpers/component-tree");
|
|
10
10
|
var _filterNodeByType = require("./helpers/filterNodeByType");
|
|
11
|
+
var _hostComponentNames = require("./helpers/host-component-names");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
const isTextInput = element => {
|
|
13
14
|
if (!element) {
|
|
@@ -17,10 +18,9 @@ const isTextInput = element => {
|
|
|
17
18
|
// We have to test if the element type is either the TextInput component
|
|
18
19
|
// (which would if it is a composite component) or the string
|
|
19
20
|
// TextInput (which would be true if it is a host component)
|
|
20
|
-
// All queries
|
|
21
|
-
// if all queries returned host components, since fireEvent bubbles up
|
|
21
|
+
// All queries return host components but since fireEvent bubbles up
|
|
22
22
|
// it would trigger the parent prop without the composite component check
|
|
23
|
-
return (0, _filterNodeByType.filterNodeByType)(element, _reactNative.TextInput) || (0, _filterNodeByType.filterNodeByType)(element,
|
|
23
|
+
return (0, _filterNodeByType.filterNodeByType)(element, _reactNative.TextInput) || (0, _filterNodeByType.filterNodeByType)(element, (0, _hostComponentNames.getHostComponentNames)().textInput);
|
|
24
24
|
};
|
|
25
25
|
const isTouchResponder = element => {
|
|
26
26
|
if (!(0, _componentTree.isHostElement)(element)) return false;
|
package/build/fireEvent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fireEvent.js","names":["isTextInput","element","filterNodeByType","TextInput","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 { TextInput } from 'react-native';\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 // 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
|
|
1
|
+
{"version":3,"file":"fireEvent.js","names":["isTextInput","element","filterNodeByType","TextInput","getHostComponentNames","textInput","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 { TextInput } from 'react-native';\nimport act from './act';\nimport { isHostElement } from './helpers/component-tree';\nimport { filterNodeByType } from './helpers/filterNodeByType';\nimport { getHostComponentNames } from './helpers/host-component-names';\n\ntype EventHandler = (...args: any) => unknown;\n\nconst isTextInput = (element?: ReactTestInstance) => {\n if (!element) {\n return false;\n }\n\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 return host components but 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, getHostComponentNames().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;AACA;AACA;AAAuE;AAIvE,MAAMA,WAAW,GAAIC,OAA2B,IAAK;EACnD,IAAI,CAACA,OAAO,EAAE;IACZ,OAAO,KAAK;EACd;;EAEA;EACA;EACA;EACA;EACA;EACA,OACE,IAAAC,kCAAgB,EAACD,OAAO,EAAEE,sBAAS,CAAC,IACpC,IAAAD,kCAAgB,EAACD,OAAO,EAAE,IAAAG,yCAAqB,GAAE,CAACC,SAAS,CAAC;AAEhE,CAAC;AAED,MAAMC,gBAAgB,GAAIL,OAA2B,IAAK;EACxD,IAAI,CAAC,IAAAM,4BAAa,EAACN,OAAO,CAAC,EAAE,OAAO,KAAK;EAEzC,OAAO,CAAC,CAACA,OAAO,EAAEO,KAAK,CAACC,yBAAyB,IAAIT,WAAW,CAACC,OAAO,CAAC;AAC3E,CAAC;AAED,MAAMS,qBAAqB,GAAG,CAC5BT,OAA2B,EAC3BU,QAAkB,KACN;EACZ,MAAMC,eAAe,GAAGD,QAAQ,GAC5BV,OAAO,EAAEO,KAAK,CAACK,aAAa,KAAK,UAAU,GAC3CZ,OAAO,EAAEO,KAAK,CAACK,aAAa,KAAK,UAAU;EAE/C,IAAIZ,OAAO,EAAEO,KAAK,CAACK,aAAa,KAAK,MAAM,IAAID,eAAe,EAAE;IAC9D,OAAO,KAA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B,KACVD,WAAW,CAAC9B,OAAO,EAAE,YAAY,EAAEsC,iBAAiB,EAAE,GAAGP,IAAI,CAAC;AACzE,MAAMQ,aAAa,GAAG,CAACvC,OAA0B,EAAE,GAAG+B,IAAgB,KACpED,WAAW,CAAC9B,OAAO,EAAE,QAAQ,EAAEuC,aAAa,EAAE,GAAGR,IAAI,CAAC;AAExD,MAAMS,SAAS,GAAG,CAChBxC,OAA0B,EAC1Be,SAAiB,EACjB,GAAGgB,IAAgB,KACVD,WAAW,CAAC9B,OAAO,EAAEe,SAAS,EAAEyB,SAAS,EAAE,GAAGT,IAAI,CAAC;AAE9DS,SAAS,CAACC,KAAK,GAAGJ,YAAY;AAC9BG,SAAS,CAACE,UAAU,GAAGJ,iBAAiB;AACxCE,SAAS,CAACG,MAAM,GAAGJ,aAAa;AAAC,eAElBC,SAAS;AAAA"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import { AccessibilityState } from 'react-native';
|
|
1
|
+
import { AccessibilityState, AccessibilityValue } from 'react-native';
|
|
2
2
|
import { ReactTestInstance } from 'react-test-renderer';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
type IsInaccessibleOptions = {
|
|
4
|
+
cache?: WeakMap<ReactTestInstance, boolean>;
|
|
5
|
+
};
|
|
6
|
+
export declare const accessibilityStateKeys: (keyof AccessibilityState)[];
|
|
7
|
+
export declare const accessiblityValueKeys: (keyof AccessibilityValue)[];
|
|
8
|
+
export declare function isHiddenFromAccessibility(element: ReactTestInstance | null, { cache }?: IsInaccessibleOptions): boolean;
|
|
9
|
+
/** RTL-compatitibility alias for `isHiddenFromAccessibility` */
|
|
10
|
+
export declare const isInaccessible: typeof isHiddenFromAccessibility;
|
|
11
|
+
export declare function isAccessibilityElement(element: ReactTestInstance | null): boolean;
|
|
12
|
+
export {};
|
|
@@ -3,30 +3,41 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.accessibilityStateKeys = void 0;
|
|
7
|
-
exports.
|
|
6
|
+
exports.accessiblityValueKeys = exports.accessibilityStateKeys = void 0;
|
|
7
|
+
exports.isAccessibilityElement = isAccessibilityElement;
|
|
8
|
+
exports.isHiddenFromAccessibility = isHiddenFromAccessibility;
|
|
9
|
+
exports.isInaccessible = void 0;
|
|
8
10
|
var _reactNative = require("react-native");
|
|
9
11
|
var _componentTree = require("./component-tree");
|
|
10
12
|
const accessibilityStateKeys = ['disabled', 'selected', 'checked', 'busy', 'expanded'];
|
|
11
13
|
exports.accessibilityStateKeys = accessibilityStateKeys;
|
|
12
|
-
|
|
14
|
+
const accessiblityValueKeys = ['min', 'max', 'now', 'text'];
|
|
15
|
+
exports.accessiblityValueKeys = accessiblityValueKeys;
|
|
16
|
+
function isHiddenFromAccessibility(element, {
|
|
17
|
+
cache
|
|
18
|
+
} = {}) {
|
|
13
19
|
if (element == null) {
|
|
14
20
|
return true;
|
|
15
21
|
}
|
|
16
22
|
let current = element;
|
|
17
23
|
while (current) {
|
|
18
|
-
|
|
24
|
+
let isCurrentSubtreeInaccessible = cache?.get(current);
|
|
25
|
+
if (isCurrentSubtreeInaccessible === undefined) {
|
|
26
|
+
isCurrentSubtreeInaccessible = isSubtreeInaccessible(current);
|
|
27
|
+
cache?.set(current, isCurrentSubtreeInaccessible);
|
|
28
|
+
}
|
|
29
|
+
if (isCurrentSubtreeInaccessible) {
|
|
19
30
|
return true;
|
|
20
31
|
}
|
|
21
32
|
current = current.parent;
|
|
22
33
|
}
|
|
23
34
|
return false;
|
|
24
35
|
}
|
|
25
|
-
function isSubtreeInaccessible(element) {
|
|
26
|
-
if (element == null) {
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
36
|
|
|
37
|
+
/** RTL-compatitibility alias for `isHiddenFromAccessibility` */
|
|
38
|
+
const isInaccessible = isHiddenFromAccessibility;
|
|
39
|
+
exports.isInaccessible = isInaccessible;
|
|
40
|
+
function isSubtreeInaccessible(element) {
|
|
30
41
|
// iOS: accessibilityElementsHidden
|
|
31
42
|
// See: https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios
|
|
32
43
|
if (element.props.accessibilityElementsHidden) {
|
|
@@ -39,7 +50,7 @@ function isSubtreeInaccessible(element) {
|
|
|
39
50
|
return true;
|
|
40
51
|
}
|
|
41
52
|
|
|
42
|
-
// Note that `opacity: 0` is not
|
|
53
|
+
// Note that `opacity: 0` is not treated as inaccessible on iOS
|
|
43
54
|
const flatStyle = _reactNative.StyleSheet.flatten(element.props.style) ?? {};
|
|
44
55
|
if (flatStyle.display === 'none') return true;
|
|
45
56
|
|
|
@@ -51,4 +62,13 @@ function isSubtreeInaccessible(element) {
|
|
|
51
62
|
}
|
|
52
63
|
return false;
|
|
53
64
|
}
|
|
65
|
+
function isAccessibilityElement(element) {
|
|
66
|
+
if (element == null) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
if (element.props.accessible !== undefined) {
|
|
70
|
+
return element.props.accessible;
|
|
71
|
+
}
|
|
72
|
+
return (0, _componentTree.isHostElementForType)(element, _reactNative.Text) || (0, _componentTree.isHostElementForType)(element, _reactNative.TextInput) || (0, _componentTree.isHostElementForType)(element, _reactNative.Switch);
|
|
73
|
+
}
|
|
54
74
|
//# sourceMappingURL=accessiblity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessiblity.js","names":["accessibilityStateKeys","
|
|
1
|
+
{"version":3,"file":"accessiblity.js","names":["accessibilityStateKeys","accessiblityValueKeys","isHiddenFromAccessibility","element","cache","current","isCurrentSubtreeInaccessible","get","undefined","isSubtreeInaccessible","set","parent","isInaccessible","props","accessibilityElementsHidden","importantForAccessibility","flatStyle","StyleSheet","flatten","style","display","hostSiblings","getHostSiblings","some","sibling","accessibilityViewIsModal","isAccessibilityElement","accessible","isHostElementForType","Text","TextInput","Switch"],"sources":["../../src/helpers/accessiblity.ts"],"sourcesContent":["import {\n AccessibilityState,\n AccessibilityValue,\n StyleSheet,\n Switch,\n Text,\n TextInput,\n} from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { getHostSiblings, isHostElementForType } from './component-tree';\n\ntype IsInaccessibleOptions = {\n cache?: WeakMap<ReactTestInstance, boolean>;\n};\n\nexport const accessibilityStateKeys: (keyof AccessibilityState)[] = [\n 'disabled',\n 'selected',\n 'checked',\n 'busy',\n 'expanded',\n];\n\nexport const accessiblityValueKeys: (keyof AccessibilityValue)[] = [\n 'min',\n 'max',\n 'now',\n 'text',\n];\n\nexport function isHiddenFromAccessibility(\n element: ReactTestInstance | null,\n { cache }: IsInaccessibleOptions = {}\n): boolean {\n if (element == null) {\n return true;\n }\n\n let current: ReactTestInstance | null = element;\n while (current) {\n let isCurrentSubtreeInaccessible = cache?.get(current);\n\n if (isCurrentSubtreeInaccessible === undefined) {\n isCurrentSubtreeInaccessible = isSubtreeInaccessible(current);\n cache?.set(current, isCurrentSubtreeInaccessible);\n }\n\n if (isCurrentSubtreeInaccessible) {\n return true;\n }\n\n current = current.parent;\n }\n\n return false;\n}\n\n/** RTL-compatitibility alias for `isHiddenFromAccessibility` */\nexport const isInaccessible = isHiddenFromAccessibility;\n\nfunction isSubtreeInaccessible(element: ReactTestInstance): boolean {\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 treated as inaccessible 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\nexport function isAccessibilityElement(\n element: ReactTestInstance | null\n): boolean {\n if (element == null) {\n return false;\n }\n\n if (element.props.accessible !== undefined) {\n return element.props.accessible;\n }\n\n return (\n isHostElementForType(element, Text) ||\n isHostElementForType(element, TextInput) ||\n isHostElementForType(element, Switch)\n );\n}\n"],"mappings":";;;;;;;;;AAAA;AASA;AAMO,MAAMA,sBAAoD,GAAG,CAClE,UAAU,EACV,UAAU,EACV,SAAS,EACT,MAAM,EACN,UAAU,CACX;AAAC;AAEK,MAAMC,qBAAmD,GAAG,CACjE,KAAK,EACL,KAAK,EACL,KAAK,EACL,MAAM,CACP;AAAC;AAEK,SAASC,yBAAyB,CACvCC,OAAiC,EACjC;EAAEC;AAA6B,CAAC,GAAG,CAAC,CAAC,EAC5B;EACT,IAAID,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,IAAI;EACb;EAEA,IAAIE,OAAiC,GAAGF,OAAO;EAC/C,OAAOE,OAAO,EAAE;IACd,IAAIC,4BAA4B,GAAGF,KAAK,EAAEG,GAAG,CAACF,OAAO,CAAC;IAEtD,IAAIC,4BAA4B,KAAKE,SAAS,EAAE;MAC9CF,4BAA4B,GAAGG,qBAAqB,CAACJ,OAAO,CAAC;MAC7DD,KAAK,EAAEM,GAAG,CAACL,OAAO,EAAEC,4BAA4B,CAAC;IACnD;IAEA,IAAIA,4BAA4B,EAAE;MAChC,OAAO,IAAI;IACb;IAEAD,OAAO,GAAGA,OAAO,CAACM,MAAM;EAC1B;EAEA,OAAO,KAAK;AACd;;AAEA;AACO,MAAMC,cAAc,GAAGV,yBAAyB;AAAC;AAExD,SAASO,qBAAqB,CAACN,OAA0B,EAAW;EAClE;EACA;EACA,IAAIA,OAAO,CAACU,KAAK,CAACC,2BAA2B,EAAE;IAC7C,OAAO,IAAI;EACb;;EAEA;EACA;EACA,IAAIX,OAAO,CAACU,KAAK,CAACE,yBAAyB,KAAK,qBAAqB,EAAE;IACrE,OAAO,IAAI;EACb;;EAEA;EACA,MAAMC,SAAS,GAAGC,uBAAU,CAACC,OAAO,CAACf,OAAO,CAACU,KAAK,CAACM,KAAK,CAAC,IAAI,CAAC,CAAC;EAC/D,IAAIH,SAAS,CAACI,OAAO,KAAK,MAAM,EAAE,OAAO,IAAI;;EAE7C;EACA;EACA,MAAMC,YAAY,GAAG,IAAAC,8BAAe,EAACnB,OAAO,CAAC;EAC7C,IAAIkB,YAAY,CAACE,IAAI,CAAEC,OAAO,IAAKA,OAAO,CAACX,KAAK,CAACY,wBAAwB,CAAC,EAAE;IAC1E,OAAO,IAAI;EACb;EAEA,OAAO,KAAK;AACd;AAEO,SAASC,sBAAsB,CACpCvB,OAAiC,EACxB;EACT,IAAIA,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,KAAK;EACd;EAEA,IAAIA,OAAO,CAACU,KAAK,CAACc,UAAU,KAAKnB,SAAS,EAAE;IAC1C,OAAOL,OAAO,CAACU,KAAK,CAACc,UAAU;EACjC;EAEA,OACE,IAAAC,mCAAoB,EAACzB,OAAO,EAAE0B,iBAAI,CAAC,IACnC,IAAAD,mCAAoB,EAACzB,OAAO,EAAE2B,sBAAS,CAAC,IACxC,IAAAF,mCAAoB,EAACzB,OAAO,EAAE4B,mBAAM,CAAC;AAEzC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
+
interface FindAllOptions {
|
|
3
|
+
/** Match elements hidden from accessibility */
|
|
4
|
+
includeHiddenElements?: boolean;
|
|
5
|
+
/** RTL-compatible alias to `includeHiddenElements` */
|
|
6
|
+
hidden?: boolean;
|
|
7
|
+
matchDeepestOnly?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function findAll(root: ReactTestInstance, predicate: (element: ReactTestInstance) => boolean, options?: FindAllOptions): ReactTestInstance[];
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findAll = findAll;
|
|
7
|
+
var _config = require("../config");
|
|
8
|
+
var _accessiblity = require("./accessiblity");
|
|
9
|
+
function findAll(root, predicate, options) {
|
|
10
|
+
const results = findAllInternal(root, predicate, options);
|
|
11
|
+
const includeHiddenElements = options?.includeHiddenElements ?? options?.hidden ?? (0, _config.getConfig)()?.defaultIncludeHiddenElements;
|
|
12
|
+
if (includeHiddenElements) {
|
|
13
|
+
return results;
|
|
14
|
+
}
|
|
15
|
+
const cache = new WeakMap();
|
|
16
|
+
return results.filter(element => !(0, _accessiblity.isHiddenFromAccessibility)(element, {
|
|
17
|
+
cache
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Extracted from React Test Renderer
|
|
22
|
+
// src: https://github.com/facebook/react/blob/8e2bde6f2751aa6335f3cef488c05c3ea08e074a/packages/react-test-renderer/src/ReactTestRenderer.js#L402
|
|
23
|
+
function findAllInternal(root, predicate, options) {
|
|
24
|
+
const results = [];
|
|
25
|
+
|
|
26
|
+
// Match descendants first but do not add them to results yet.
|
|
27
|
+
const matchingDescendants = [];
|
|
28
|
+
root.children.forEach(child => {
|
|
29
|
+
if (typeof child === 'string') {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
matchingDescendants.push(...findAllInternal(child, predicate, options));
|
|
33
|
+
});
|
|
34
|
+
if (
|
|
35
|
+
// When matchDeepestOnly = true: add current element only if no descendants match
|
|
36
|
+
(!options?.matchDeepestOnly || matchingDescendants.length === 0) && predicate(root)) {
|
|
37
|
+
results.push(root);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Add matching descendants after element to preserve original tree walk order.
|
|
41
|
+
results.push(...matchingDescendants);
|
|
42
|
+
return results;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=findAll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findAll.js","names":["findAll","root","predicate","options","results","findAllInternal","includeHiddenElements","hidden","getConfig","defaultIncludeHiddenElements","cache","WeakMap","filter","element","isHiddenFromAccessibility","matchingDescendants","children","forEach","child","push","matchDeepestOnly","length"],"sources":["../../src/helpers/findAll.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { getConfig } from '../config';\nimport { isHiddenFromAccessibility } from './accessiblity';\n\ninterface FindAllOptions {\n /** Match elements hidden from accessibility */\n includeHiddenElements?: boolean;\n\n /** RTL-compatible alias to `includeHiddenElements` */\n hidden?: boolean;\n\n /* Exclude any ancestors of deepest matched elements even if they match the predicate */\n matchDeepestOnly?: boolean;\n}\n\nexport function findAll(\n root: ReactTestInstance,\n predicate: (element: ReactTestInstance) => boolean,\n options?: FindAllOptions\n) {\n const results = findAllInternal(root, predicate, options);\n\n const includeHiddenElements =\n options?.includeHiddenElements ??\n options?.hidden ??\n getConfig()?.defaultIncludeHiddenElements;\n\n if (includeHiddenElements) {\n return results;\n }\n\n const cache = new WeakMap<ReactTestInstance>();\n return results.filter(\n (element) => !isHiddenFromAccessibility(element, { cache })\n );\n}\n\n// Extracted from React Test Renderer\n// src: https://github.com/facebook/react/blob/8e2bde6f2751aa6335f3cef488c05c3ea08e074a/packages/react-test-renderer/src/ReactTestRenderer.js#L402\nfunction findAllInternal(\n root: ReactTestInstance,\n predicate: (element: ReactTestInstance) => boolean,\n options?: FindAllOptions\n): Array<ReactTestInstance> {\n const results: ReactTestInstance[] = [];\n\n // Match descendants first but do not add them to results yet.\n const matchingDescendants: ReactTestInstance[] = [];\n root.children.forEach((child) => {\n if (typeof child === 'string') {\n return;\n }\n matchingDescendants.push(...findAllInternal(child, predicate, options));\n });\n\n if (\n // When matchDeepestOnly = true: add current element only if no descendants match\n (!options?.matchDeepestOnly || matchingDescendants.length === 0) &&\n predicate(root)\n ) {\n results.push(root);\n }\n\n // Add matching descendants after element to preserve original tree walk order.\n results.push(...matchingDescendants);\n\n return results;\n}\n"],"mappings":";;;;;;AAC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
-
|
|
3
|
-
export
|
|
2
|
+
type MapPropsFunction = (props: Record<string, unknown>, node: ReactTestRendererJSON) => Record<string, unknown>;
|
|
3
|
+
export type FormatOptions = {
|
|
4
4
|
mapProps?: MapPropsFunction;
|
|
5
5
|
};
|
|
6
6
|
declare const format: (input: ReactTestRendererJSON | ReactTestRendererJSON[], options?: FormatOptions) => string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getTextContent = getTextContent;
|
|
7
|
+
function getTextContent(element) {
|
|
8
|
+
if (!element) {
|
|
9
|
+
return '';
|
|
10
|
+
}
|
|
11
|
+
if (typeof element === 'string') {
|
|
12
|
+
return element;
|
|
13
|
+
}
|
|
14
|
+
const result = [];
|
|
15
|
+
element.children?.forEach(child => {
|
|
16
|
+
result.push(getTextContent(child));
|
|
17
|
+
});
|
|
18
|
+
return result.join('');
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=getTextContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTextContent.js","names":["getTextContent","element","result","children","forEach","child","push","join"],"sources":["../../src/helpers/getTextContent.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\n\nexport function getTextContent(\n element: ReactTestInstance | string | null\n): string {\n if (!element) {\n return '';\n }\n\n if (typeof element === 'string') {\n return element;\n }\n\n const result: string[] = [];\n element.children?.forEach((child) => {\n result.push(getTextContent(child));\n });\n\n return result.join('');\n}\n"],"mappings":";;;;;;AAEO,SAASA,cAAc,CAC5BC,OAA0C,EAClC;EACR,IAAI,CAACA,OAAO,EAAE;IACZ,OAAO,EAAE;EACX;EAEA,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;IAC/B,OAAOA,OAAO;EAChB;EAEA,MAAMC,MAAgB,GAAG,EAAE;EAC3BD,OAAO,CAACE,QAAQ,EAAEC,OAAO,CAAEC,KAAK,IAAK;IACnCH,MAAM,CAACI,IAAI,CAACN,cAAc,CAACK,KAAK,CAAC,CAAC;EACpC,CAAC,CAAC;EAEF,OAAOH,MAAM,CAACK,IAAI,CAAC,EAAE,CAAC;AACxB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getHostComponentNames = getHostComponentNames;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactTestRenderer = _interopRequireDefault(require("react-test-renderer"));
|
|
10
|
+
var _config = require("../config");
|
|
11
|
+
var _within = require("../within");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
const defaultErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.
|
|
14
|
+
Please check if you are using compatible versions of React Native and React Native Testing Library.`;
|
|
15
|
+
function getHostComponentNames() {
|
|
16
|
+
const configHostComponentNames = (0, _config.getConfig)().hostComponentNames;
|
|
17
|
+
if (configHostComponentNames) {
|
|
18
|
+
return configHostComponentNames;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const renderer = _reactTestRenderer.default.create( /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
22
|
+
testID: "text"
|
|
23
|
+
}, "Hello"), /*#__PURE__*/_react.default.createElement(_reactNative.TextInput, {
|
|
24
|
+
testID: "textInput"
|
|
25
|
+
})));
|
|
26
|
+
const {
|
|
27
|
+
getByTestId
|
|
28
|
+
} = (0, _within.getQueriesForElement)(renderer.root);
|
|
29
|
+
const textHostName = getByTestId('text').type;
|
|
30
|
+
const textInputHostName = getByTestId('textInput').type;
|
|
31
|
+
|
|
32
|
+
// This code path should not happen as getByTestId always returns host elements.
|
|
33
|
+
if (typeof textHostName !== 'string' || typeof textInputHostName !== 'string') {
|
|
34
|
+
throw new Error('getByTestId returned non-host component');
|
|
35
|
+
}
|
|
36
|
+
const hostComponentNames = {
|
|
37
|
+
text: textHostName,
|
|
38
|
+
textInput: textInputHostName
|
|
39
|
+
};
|
|
40
|
+
(0, _config.configureInternal)({
|
|
41
|
+
hostComponentNames
|
|
42
|
+
});
|
|
43
|
+
return hostComponentNames;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
const errorMessage = error && typeof error === 'object' && 'message' in error ? error.message : null;
|
|
46
|
+
throw new Error(`Trying to detect host component names triggered the following error:\n\n${errorMessage}\n\n${defaultErrorMessage}
|
|
47
|
+
`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=host-component-names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-component-names.js","names":["defaultErrorMessage","getHostComponentNames","configHostComponentNames","getConfig","hostComponentNames","renderer","TestRenderer","create","getByTestId","getQueriesForElement","root","textHostName","type","textInputHostName","Error","text","textInput","configureInternal","error","errorMessage","message"],"sources":["../../src/helpers/host-component-names.tsx"],"sourcesContent":["import React from 'react';\nimport { Text, TextInput, View } from 'react-native';\nimport TestRenderer from 'react-test-renderer';\nimport { configureInternal, getConfig, HostComponentNames } from '../config';\nimport { getQueriesForElement } from '../within';\n\nconst defaultErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.\nPlease check if you are using compatible versions of React Native and React Native Testing Library.`;\n\nexport function getHostComponentNames(): HostComponentNames {\n const configHostComponentNames = getConfig().hostComponentNames;\n if (configHostComponentNames) {\n return configHostComponentNames;\n }\n\n try {\n const renderer = TestRenderer.create(\n <View>\n <Text testID=\"text\">Hello</Text>\n <TextInput testID=\"textInput\" />\n </View>\n );\n const { getByTestId } = getQueriesForElement(renderer.root);\n const textHostName = getByTestId('text').type;\n const textInputHostName = getByTestId('textInput').type;\n\n // This code path should not happen as getByTestId always returns host elements.\n if (\n typeof textHostName !== 'string' ||\n typeof textInputHostName !== 'string'\n ) {\n throw new Error('getByTestId returned non-host component');\n }\n\n const hostComponentNames = {\n text: textHostName,\n textInput: textInputHostName,\n };\n configureInternal({ hostComponentNames });\n return hostComponentNames;\n } catch (error) {\n const errorMessage =\n error && typeof error === 'object' && 'message' in error\n ? error.message\n : null;\n\n throw new Error(`Trying to detect host component names triggered the following error:\\n\\n${errorMessage}\\n\\n${defaultErrorMessage}\n`);\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AAAiD;AAEjD,MAAMA,mBAAmB,GAAI;AAC7B,oGAAoG;AAE7F,SAASC,qBAAqB,GAAuB;EAC1D,MAAMC,wBAAwB,GAAG,IAAAC,iBAAS,GAAE,CAACC,kBAAkB;EAC/D,IAAIF,wBAAwB,EAAE;IAC5B,OAAOA,wBAAwB;EACjC;EAEA,IAAI;IACF,MAAMG,QAAQ,GAAGC,0BAAY,CAACC,MAAM,eAClC,6BAAC,iBAAI,qBACH,6BAAC,iBAAI;MAAC,MAAM,EAAC;IAAM,GAAC,OAAK,CAAO,eAChC,6BAAC,sBAAS;MAAC,MAAM,EAAC;IAAW,EAAG,CAC3B,CACR;IACD,MAAM;MAAEC;IAAY,CAAC,GAAG,IAAAC,4BAAoB,EAACJ,QAAQ,CAACK,IAAI,CAAC;IAC3D,MAAMC,YAAY,GAAGH,WAAW,CAAC,MAAM,CAAC,CAACI,IAAI;IAC7C,MAAMC,iBAAiB,GAAGL,WAAW,CAAC,WAAW,CAAC,CAACI,IAAI;;IAEvD;IACA,IACE,OAAOD,YAAY,KAAK,QAAQ,IAChC,OAAOE,iBAAiB,KAAK,QAAQ,EACrC;MACA,MAAM,IAAIC,KAAK,CAAC,yCAAyC,CAAC;IAC5D;IAEA,MAAMV,kBAAkB,GAAG;MACzBW,IAAI,EAAEJ,YAAY;MAClBK,SAAS,EAAEH;IACb,CAAC;IACD,IAAAI,yBAAiB,EAAC;MAAEb;IAAmB,CAAC,CAAC;IACzC,OAAOA,kBAAkB;EAC3B,CAAC,CAAC,OAAOc,KAAK,EAAE;IACd,MAAMC,YAAY,GAChBD,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAIA,KAAK,GACpDA,KAAK,CAACE,OAAO,GACb,IAAI;IAEV,MAAM,IAAIN,KAAK,CAAE,2EAA0EK,YAAa,OAAMnB,mBAAoB;AACtI,CAAC,CAAC;EACA;AACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
+
import { TextMatch } from '../../matches';
|
|
3
|
+
export interface AccessibilityValueMatcher {
|
|
4
|
+
min?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
now?: number;
|
|
7
|
+
text?: TextMatch;
|
|
8
|
+
}
|
|
9
|
+
export declare function matchAccessibilityValue(node: ReactTestInstance, matcher: AccessibilityValueMatcher): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.matchAccessibilityValue = matchAccessibilityValue;
|
|
7
|
+
var _matchStringProp = require("./matchStringProp");
|
|
8
|
+
function matchAccessibilityValue(node, matcher) {
|
|
9
|
+
const value = node.props.accessibilityValue ?? {};
|
|
10
|
+
return (matcher.min === undefined || matcher.min === value.min) && (matcher.max === undefined || matcher.max === value.max) && (matcher.now === undefined || matcher.now === value.now) && (matcher.text === undefined || (0, _matchStringProp.matchStringProp)(value.text, matcher.text));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=accessibilityValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessibilityValue.js","names":["matchAccessibilityValue","node","matcher","value","props","accessibilityValue","min","undefined","max","now","text","matchStringProp"],"sources":["../../../src/helpers/matchers/accessibilityValue.ts"],"sourcesContent":["import { AccessibilityValue } from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { TextMatch } from '../../matches';\nimport { matchStringProp } from './matchStringProp';\n\nexport interface AccessibilityValueMatcher {\n min?: number;\n max?: number;\n now?: number;\n text?: TextMatch;\n}\n\nexport function matchAccessibilityValue(\n node: ReactTestInstance,\n matcher: AccessibilityValueMatcher\n): boolean {\n const value: AccessibilityValue = node.props.accessibilityValue ?? {};\n return (\n (matcher.min === undefined || matcher.min === value.min) &&\n (matcher.max === undefined || matcher.max === value.max) &&\n (matcher.now === undefined || matcher.now === value.now) &&\n (matcher.text === undefined || matchStringProp(value.text, matcher.text))\n );\n}\n"],"mappings":";;;;;;AAGA;AASO,SAASA,uBAAuB,CACrCC,IAAuB,EACvBC,OAAkC,EACzB;EACT,MAAMC,KAAyB,GAAGF,IAAI,CAACG,KAAK,CAACC,kBAAkB,IAAI,CAAC,CAAC;EACrE,OACE,CAACH,OAAO,CAACI,GAAG,KAAKC,SAAS,IAAIL,OAAO,CAACI,GAAG,KAAKH,KAAK,CAACG,GAAG,MACtDJ,OAAO,CAACM,GAAG,KAAKD,SAAS,IAAIL,OAAO,CAACM,GAAG,KAAKL,KAAK,CAACK,GAAG,CAAC,KACvDN,OAAO,CAACO,GAAG,KAAKF,SAAS,IAAIL,OAAO,CAACO,GAAG,KAAKN,KAAK,CAACM,GAAG,CAAC,KACvDP,OAAO,CAACQ,IAAI,KAAKH,SAAS,IAAI,IAAAI,gCAAe,EAACR,KAAK,CAACO,IAAI,EAAER,OAAO,CAACQ,IAAI,CAAC,CAAC;AAE7E"}
|