@testing-library/react-native 12.1.1 → 12.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.DS_Store +0 -0
- package/.codecov.yml +9 -0
- package/.eslintcache +1 -0
- package/.eslintignore +2 -0
- package/.eslintrc +19 -0
- package/.flowconfig +63 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +14 -0
- package/.github/ISSUE_TEMPLATE/question.md +9 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +10 -0
- package/.github/actions/setup-deps/action.yml +22 -0
- package/.github/actions/setup-website-deps/action.yml +22 -0
- package/.github/dependabot.yml +10 -0
- package/.github/workflows/deploy-website.yml +36 -0
- package/.github/workflows/example-apps.yml +25 -0
- package/.github/workflows/main.yml +103 -0
- package/.gitignore +11 -0
- package/.prettierrc.js +5 -0
- package/CODE_OF_CONDUCT.md +73 -0
- package/CONTRIBUTING.md +64 -0
- package/README.md +8 -7
- package/babel.config.js +22 -0
- package/build/act.js.map +1 -1
- package/build/cleanup.js.map +1 -1
- package/build/config.d.ts +1 -0
- package/build/config.js.map +1 -1
- package/build/fireEvent.d.ts +13 -5
- package/build/fireEvent.js +57 -48
- package/build/fireEvent.js.map +1 -1
- package/build/flush-micro-tasks.d.ts +19 -0
- package/build/flush-micro-tasks.js +36 -0
- package/build/flush-micro-tasks.js.map +1 -0
- package/build/helpers/accessiblity.js +3 -1
- package/build/helpers/accessiblity.js.map +1 -1
- package/build/helpers/component-tree.d.ts +0 -15
- package/build/helpers/component-tree.js +0 -45
- package/build/helpers/component-tree.js.map +1 -1
- package/build/helpers/deprecation.d.ts +1 -0
- package/build/helpers/deprecation.js +16 -0
- package/build/helpers/deprecation.js.map +1 -1
- package/build/helpers/errors.d.ts +0 -4
- package/build/helpers/errors.js +1 -25
- package/build/helpers/errors.js.map +1 -1
- package/build/helpers/findAll.js.map +1 -1
- package/build/helpers/format-default.js.map +1 -1
- package/build/helpers/format.js.map +1 -1
- package/build/helpers/host-component-names.js +4 -1
- package/build/helpers/host-component-names.js.map +1 -1
- package/build/helpers/matchers/matchLabelText.js.map +1 -1
- package/build/helpers/pointer-events.d.ts +9 -0
- package/build/helpers/pointer-events.js +25 -0
- package/build/helpers/pointer-events.js.map +1 -0
- package/build/helpers/stringValidation.js.map +1 -1
- package/build/helpers/timers.js.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/matches.js.map +1 -1
- package/build/pure.d.ts +1 -1
- 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.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/render.d.ts +171 -12
- package/build/render.js +11 -4
- package/build/render.js.map +1 -1
- package/build/renderHook.d.ts +3 -6
- package/build/renderHook.js +4 -3
- package/build/renderHook.js.map +1 -1
- package/build/shallow.js.map +1 -1
- package/build/test-utils/events.d.ts +10 -0
- package/build/test-utils/events.js +27 -0
- package/build/test-utils/events.js.map +1 -0
- package/build/test-utils/index.d.ts +1 -0
- package/build/test-utils/index.js +17 -0
- package/build/test-utils/index.js.map +1 -0
- package/build/user-event/event-builder/common.d.ts +45 -0
- package/build/user-event/event-builder/common.js +58 -0
- package/build/user-event/event-builder/common.js.map +1 -0
- package/build/user-event/event-builder/index.d.ts +32 -0
- package/build/user-event/event-builder/index.js +12 -0
- package/build/user-event/event-builder/index.js.map +1 -0
- package/build/user-event/index.d.ts +9 -0
- package/build/user-event/index.js +16 -0
- package/build/user-event/index.js.map +1 -0
- package/build/user-event/press/constants.d.ts +2 -0
- package/build/user-event/press/constants.js +16 -0
- package/build/user-event/press/constants.js.map +1 -0
- package/build/user-event/press/index.d.ts +1 -0
- package/build/user-event/press/index.js +19 -0
- package/build/user-event/press/index.js.map +1 -0
- package/build/user-event/press/press.d.ts +7 -0
- package/build/user-event/press/press.js +106 -0
- package/build/user-event/press/press.js.map +1 -0
- package/build/user-event/press/utils/warnAboutRealTimers.d.ts +1 -0
- package/build/user-event/press/utils/warnAboutRealTimers.js +14 -0
- package/build/user-event/press/utils/warnAboutRealTimers.js.map +1 -0
- package/build/user-event/setup/index.d.ts +2 -0
- package/build/user-event/setup/index.js +13 -0
- package/build/user-event/setup/index.js.map +1 -0
- package/build/user-event/setup/setup.d.ts +39 -0
- package/build/user-event/setup/setup.js +56 -0
- package/build/user-event/setup/setup.js.map +1 -0
- package/build/user-event/type/index.d.ts +1 -0
- package/build/user-event/type/index.js +13 -0
- package/build/user-event/type/index.js.map +1 -0
- package/build/user-event/type/type.d.ts +3 -0
- package/build/user-event/type/type.js +18 -0
- package/build/user-event/type/type.js.map +1 -0
- package/build/user-event/utils/events.d.ts +9 -0
- package/build/user-event/utils/events.js +44 -0
- package/build/user-event/utils/events.js.map +1 -0
- package/build/user-event/utils/index.d.ts +2 -0
- package/build/user-event/utils/index.js +28 -0
- package/build/user-event/utils/index.js.map +1 -0
- package/build/user-event/utils/wait.d.ts +2 -0
- package/build/user-event/utils/wait.js +14 -0
- package/build/user-event/utils/wait.js.map +1 -0
- package/build/waitFor.js +3 -3
- package/build/waitFor.js.map +1 -1
- package/build/waitForElementToBeRemoved.js.map +1 -1
- package/examples/basic/.expo-shared/assets.json +4 -0
- package/examples/basic/.gitignore +14 -0
- package/examples/basic/App.tsx +20 -0
- package/examples/basic/README.md +11 -0
- package/examples/basic/__tests__/App.test.tsx +119 -0
- package/examples/basic/app.json +31 -0
- package/examples/basic/assets/adaptive-icon.png +0 -0
- package/examples/basic/assets/favicon.png +0 -0
- package/examples/basic/assets/icon.png +0 -0
- package/examples/basic/assets/splash.png +0 -0
- package/examples/basic/babel.config.js +6 -0
- package/examples/basic/components/Home.tsx +28 -0
- package/examples/basic/components/LoginForm.tsx +138 -0
- package/examples/basic/jest-setup.ts +7 -0
- package/examples/basic/jest.config.js +5 -0
- package/examples/basic/package.json +30 -0
- package/examples/basic/tsconfig.json +7 -0
- package/examples/react-navigation/README.md +14 -0
- package/examples/react-navigation/babel.config.js +4 -0
- package/examples/react-navigation/jest-setup.js +11 -0
- package/examples/react-navigation/jest.config.js +10 -0
- package/examples/react-navigation/package.json +31 -0
- package/examples/react-navigation/src/App.js +21 -0
- package/examples/react-navigation/src/DrawerNavigator.js +15 -0
- package/examples/react-navigation/src/DrawerNavigator.test.js +42 -0
- package/examples/react-navigation/src/NativeStackNavigator.js +15 -0
- package/examples/react-navigation/src/NativeStackNavigator.test.js +34 -0
- package/examples/react-navigation/src/StackNavigator.js +15 -0
- package/examples/react-navigation/src/StackNavigator.test.js +34 -0
- package/examples/react-navigation/src/TabNavigator.js +15 -0
- package/examples/react-navigation/src/TabNavigator.test.js +21 -0
- package/examples/react-navigation/src/screens/DetailsScreen.js +43 -0
- package/examples/react-navigation/src/screens/DetailsScreen.test.js +27 -0
- package/examples/react-navigation/src/screens/DrawerHomeScreen.js +26 -0
- package/examples/react-navigation/src/screens/HomeScreen.js +48 -0
- package/examples/react-navigation/src/screens/SettingsScreen.js +20 -0
- package/examples/react-navigation/src/test-utils.js +12 -0
- package/examples/redux/App.js +27 -0
- package/examples/redux/actions/todoActions.js +25 -0
- package/examples/redux/babel.config.js +6 -0
- package/examples/redux/components/AddTodo.js +73 -0
- package/examples/redux/components/AddTodo.test.js +27 -0
- package/examples/redux/components/TodoElem.js +25 -0
- package/examples/redux/components/TodoList.js +29 -0
- package/examples/redux/components/TodoList.test.js +34 -0
- package/examples/redux/index.js +8 -0
- package/examples/redux/jest-setup.js +2 -0
- package/examples/redux/jest.config.js +4 -0
- package/examples/redux/package.json +23 -0
- package/examples/redux/reducers/index.js +6 -0
- package/examples/redux/reducers/todoReducer.js +27 -0
- package/examples/redux/store.js +10 -0
- package/examples/redux/test-utils.js +11 -0
- package/experiments-app/.expo/README.md +15 -0
- package/experiments-app/.expo/devices.json +3 -0
- package/experiments-app/.expo/packager-info.json +9 -0
- package/experiments-app/.expo/settings.json +9 -0
- package/experiments-app/.gitignore +17 -0
- package/experiments-app/.prettierrc.js +5 -0
- package/experiments-app/app.json +30 -0
- package/experiments-app/assets/adaptive-icon.png +0 -0
- package/experiments-app/assets/favicon.png +0 -0
- package/experiments-app/assets/icon.png +0 -0
- package/experiments-app/assets/splash.png +0 -0
- package/experiments-app/babel.config.js +6 -0
- package/experiments-app/index.js +4 -0
- package/experiments-app/package.json +31 -0
- package/experiments-app/src/App.tsx +31 -0
- package/experiments-app/src/MainScreen.tsx +51 -0
- package/experiments-app/src/experiments.ts +17 -0
- package/experiments-app/src/screens/TextInputEventPropagation.tsx +54 -0
- package/experiments-app/src/screens/TextInputEvents.tsx +50 -0
- package/experiments-app/src/utils/helpers.ts +8 -0
- package/experiments-app/tsconfig.json +6 -0
- package/experiments-app/yarn.lock +6913 -0
- package/flow-typed/npm/jest_v26.x.x.js +1218 -0
- package/flow-typed/npm/react-test-renderer_v16.x.x.js +81 -0
- package/jest-setup.ts +10 -0
- package/package.json +6 -6
- package/renovate.json +19 -0
- package/scripts/test_react_17 +12 -0
- package/src/__tests__/__snapshots__/render-debug.test.tsx.snap +548 -0
- package/src/__tests__/__snapshots__/render.test.tsx.snap +39 -0
- package/src/__tests__/act.test.tsx +52 -0
- package/src/__tests__/auto-cleanup-skip.test.tsx +39 -0
- package/src/__tests__/auto-cleanup.test.tsx +50 -0
- package/src/__tests__/cleanup.test.tsx +26 -0
- package/src/__tests__/config.test.ts +55 -0
- package/src/__tests__/fireEvent-textInput.test.tsx +154 -0
- package/src/__tests__/fireEvent.test.tsx +485 -0
- package/src/__tests__/host-component-names.test.tsx +109 -0
- package/src/__tests__/host-text-nesting.test.tsx +90 -0
- package/src/__tests__/jest-native.test.tsx +84 -0
- package/src/__tests__/questionsBoard.test.tsx +62 -0
- package/src/__tests__/react-native-api.test.tsx +126 -0
- package/src/__tests__/render-debug.test.tsx +207 -0
- package/src/__tests__/render-stringValidation.test.tsx +157 -0
- package/src/__tests__/render.test.tsx +256 -0
- package/src/__tests__/renderHook.test.tsx +114 -0
- package/src/__tests__/screen.test.tsx +66 -0
- package/src/__tests__/timerUtils.ts +7 -0
- package/src/__tests__/timers.test.ts +27 -0
- package/src/__tests__/waitFor.test.tsx +327 -0
- package/src/__tests__/waitForElementToBeRemoved.test.tsx +151 -0
- package/src/__tests__/within.test.tsx +96 -0
- package/src/act.ts +86 -0
- package/src/cleanup.ts +15 -0
- package/src/config.ts +72 -0
- package/src/fireEvent.ts +163 -0
- package/src/flush-micro-tasks.ts +30 -0
- package/src/helpers/__tests__/accessiblity.test.tsx +373 -0
- package/src/helpers/__tests__/component-tree.test.tsx +226 -0
- package/src/helpers/__tests__/format-default.tsx +114 -0
- package/src/helpers/__tests__/getTextContent.test.tsx +49 -0
- package/src/helpers/__tests__/includeHiddenElements.test.tsx +39 -0
- package/src/helpers/__tests__/query-name.test.ts +10 -0
- package/src/helpers/__tests__/timers.test.ts +8 -0
- package/src/helpers/accessiblity.ts +108 -0
- package/src/helpers/component-tree.ts +89 -0
- package/src/helpers/debugDeep.ts +27 -0
- package/src/helpers/debugShallow.ts +22 -0
- package/src/helpers/deprecation.ts +53 -0
- package/src/helpers/errors.ts +66 -0
- package/src/helpers/filterNodeByType.ts +7 -0
- package/src/helpers/findAll.ts +68 -0
- package/src/helpers/format-default.ts +72 -0
- package/src/helpers/format.ts +47 -0
- package/src/helpers/getTextContent.ts +20 -0
- package/src/helpers/host-component-names.tsx +67 -0
- package/src/helpers/matchers/__tests__/matchArrayValue.test.ts +34 -0
- package/src/helpers/matchers/__tests__/matchObject.test.ts +37 -0
- package/src/helpers/matchers/__tests__/matchStringValue.test.ts +15 -0
- package/src/helpers/matchers/accessibilityState.ts +48 -0
- package/src/helpers/matchers/accessibilityValue.ts +24 -0
- package/src/helpers/matchers/matchArrayProp.ts +21 -0
- package/src/helpers/matchers/matchLabelText.ts +51 -0
- package/src/helpers/matchers/matchObjectProp.ts +25 -0
- package/src/helpers/matchers/matchStringProp.ts +23 -0
- package/src/helpers/matchers/matchTextContent.ts +20 -0
- package/src/helpers/pointer-events.ts +27 -0
- package/src/helpers/query-name.ts +4 -0
- package/src/helpers/stringValidation.ts +36 -0
- package/src/helpers/timers.ts +98 -0
- package/src/index.ts +33 -0
- package/src/matches.ts +49 -0
- package/src/pure.ts +25 -0
- package/src/queries/__tests__/a11yState.test.tsx +439 -0
- package/src/queries/__tests__/a11yValue.test.tsx +309 -0
- package/src/queries/__tests__/displayValue.test.tsx +221 -0
- package/src/queries/__tests__/hintText.test.tsx +177 -0
- package/src/queries/__tests__/labelText.test.tsx +242 -0
- package/src/queries/__tests__/makeQueries.test.tsx +235 -0
- package/src/queries/__tests__/placeholderText.test.tsx +136 -0
- package/src/queries/__tests__/role-value.test.tsx +176 -0
- package/src/queries/__tests__/role.test.tsx +824 -0
- package/src/queries/__tests__/testId.test.tsx +200 -0
- package/src/queries/__tests__/text.test.tsx +556 -0
- package/src/queries/a11yState.ts +131 -0
- package/src/queries/a11yValue.ts +131 -0
- package/src/queries/displayValue.ts +78 -0
- package/src/queries/hintText.ts +112 -0
- package/src/queries/labelText.ts +59 -0
- package/src/queries/makeQueries.ts +255 -0
- package/src/queries/options.ts +14 -0
- package/src/queries/placeholderText.ts +79 -0
- package/src/queries/role.ts +132 -0
- package/src/queries/testId.ts +71 -0
- package/src/queries/text.ts +66 -0
- package/src/queries/unsafeProps.ts +76 -0
- package/src/queries/unsafeType.ts +73 -0
- package/src/react-versions.ts +11 -0
- package/src/render-act.ts +19 -0
- package/src/render.tsx +183 -0
- package/src/renderHook.tsx +56 -0
- package/src/screen.ts +123 -0
- package/src/shallow.ts +18 -0
- package/src/test-utils/events.ts +24 -0
- package/src/test-utils/index.ts +1 -0
- package/src/user-event/event-builder/common.ts +50 -0
- package/src/user-event/event-builder/index.ts +5 -0
- package/src/user-event/index.ts +14 -0
- package/src/user-event/press/__tests__/longPress.real-timers.test.tsx +115 -0
- package/src/user-event/press/__tests__/longPress.test.tsx +157 -0
- package/src/user-event/press/__tests__/press.real-timers.test.tsx +318 -0
- package/src/user-event/press/__tests__/press.test.tsx +422 -0
- package/src/user-event/press/constants.ts +7 -0
- package/src/user-event/press/index.ts +1 -0
- package/src/user-event/press/press.ts +134 -0
- package/src/user-event/press/utils/warnAboutRealTimers.ts +6 -0
- package/src/user-event/setup/index.ts +2 -0
- package/src/user-event/setup/setup.ts +93 -0
- package/src/user-event/type/__tests__/__snapshots__/type.test.tsx.snap +26 -0
- package/src/user-event/type/__tests__/type.test.tsx +63 -0
- package/src/user-event/type/index.ts +1 -0
- package/src/user-event/type/type.ts +20 -0
- package/src/user-event/utils/__tests__/wait.test.ts +63 -0
- package/src/user-event/utils/events.ts +54 -0
- package/src/user-event/utils/index.ts +2 -0
- package/src/user-event/utils/wait.ts +15 -0
- package/src/waitFor.ts +228 -0
- package/src/waitForElementToBeRemoved.ts +42 -0
- package/src/within.ts +30 -0
- package/tsconfig.json +17 -0
- package/tsconfig.release.json +8 -0
- package/website/.gitignore +20 -0
- package/website/README.md +33 -0
- package/website/docker/.dockerignore +3 -0
- package/website/docker/Dockerfile +9 -0
- package/website/docker/docker-compose.yml +11 -0
- package/website/docs/API.md +946 -0
- package/website/docs/EslintPLluginTestingLibrary.md +28 -0
- package/website/docs/FAQ.md +44 -0
- package/website/docs/GettingStarted.md +100 -0
- package/website/docs/HowShouldIQuery.md +21 -0
- package/website/docs/MigrationV11.md +64 -0
- package/website/docs/MigrationV12.md +67 -0
- package/website/docs/MigrationV2.md +126 -0
- package/website/docs/MigrationV7.md +119 -0
- package/website/docs/MigrationV9.md +67 -0
- package/website/docs/Queries.md +567 -0
- package/website/docs/ReactNavigation.md +371 -0
- package/website/docs/ReduxIntegration.md +137 -0
- package/website/docs/TestingEnvironment.md +154 -0
- package/website/docs/Troubleshooting.md +44 -0
- package/website/docs/UnderstandingAct.md +227 -0
- package/website/docs/UserEvent.md +66 -0
- package/website/docusaurus.config.js +114 -0
- package/website/package.json +31 -0
- package/website/sidebars.js +20 -0
- package/website/src/components/Feature.js +31 -0
- package/website/src/css/custom.css +13 -0
- package/website/src/css/index.module.css +77 -0
- package/website/src/pages/index.js +82 -0
- package/website/static/.nojekyll +0 -0
- package/website/static/css/custom.css +28 -0
- package/website/static/img/hit.png +0 -0
- package/website/static/img/locomotive.png +0 -0
- package/website/static/img/owl.png +0 -0
- package/website/static/img/tools.png +0 -0
- package/website/yarn.lock +7669 -0
- package/yarn.lock +7765 -0
- package/build/flushMicroTasks.d.ts +0 -5
- package/build/flushMicroTasks.js +0 -17
- package/build/flushMicroTasks.js.map +0 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ReactTestInstance } from 'react-test-renderer';
|
|
3
2
|
/**
|
|
4
3
|
* Checks if the given element is a host element.
|
|
@@ -15,15 +14,6 @@ export declare function getHostParent(element: ReactTestInstance | null): ReactT
|
|
|
15
14
|
* @param element The element start traversing from.
|
|
16
15
|
*/
|
|
17
16
|
export declare function getHostChildren(element: ReactTestInstance | null): ReactTestInstance[];
|
|
18
|
-
/**
|
|
19
|
-
* Return a single host element that represent the passed host or composite element.
|
|
20
|
-
*
|
|
21
|
-
* @param element The element start traversing from.
|
|
22
|
-
* @throws Error if the passed element is a composite element and has no host children or has more than one host child.
|
|
23
|
-
* @returns If the passed element is a host element, it will return itself, if the passed element is a composite
|
|
24
|
-
* element, it will return a single host descendant.
|
|
25
|
-
*/
|
|
26
|
-
export declare function getHostSelf(element: ReactTestInstance | null): ReactTestInstance;
|
|
27
17
|
/**
|
|
28
18
|
* Return the array of host elements that represent the passed element.
|
|
29
19
|
*
|
|
@@ -37,8 +27,3 @@ export declare function getHostSelves(element: ReactTestInstance | null): ReactT
|
|
|
37
27
|
* @param element The element start traversing from.
|
|
38
28
|
*/
|
|
39
29
|
export declare function getHostSiblings(element: ReactTestInstance | null): ReactTestInstance[];
|
|
40
|
-
export declare function getCompositeParentOfType(element: ReactTestInstance, type: React.ComponentType): ReactTestInstance | null;
|
|
41
|
-
/**
|
|
42
|
-
* Note: this function should be generally used for core React Native types like `View`, `Text`, `TextInput`, etc.
|
|
43
|
-
*/
|
|
44
|
-
export declare function isHostElementForType(element: ReactTestInstance, type: React.ComponentType): boolean;
|
|
@@ -3,14 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getCompositeParentOfType = getCompositeParentOfType;
|
|
7
6
|
exports.getHostChildren = getHostChildren;
|
|
8
7
|
exports.getHostParent = getHostParent;
|
|
9
|
-
exports.getHostSelf = getHostSelf;
|
|
10
8
|
exports.getHostSelves = getHostSelves;
|
|
11
9
|
exports.getHostSiblings = getHostSiblings;
|
|
12
10
|
exports.isHostElement = isHostElement;
|
|
13
|
-
exports.isHostElementForType = isHostElementForType;
|
|
14
11
|
/**
|
|
15
12
|
* Checks if the given element is a host element.
|
|
16
13
|
* @param element The element to check.
|
|
@@ -59,25 +56,6 @@ function getHostChildren(element) {
|
|
|
59
56
|
return hostChildren;
|
|
60
57
|
}
|
|
61
58
|
|
|
62
|
-
/**
|
|
63
|
-
* Return a single host element that represent the passed host or composite element.
|
|
64
|
-
*
|
|
65
|
-
* @param element The element start traversing from.
|
|
66
|
-
* @throws Error if the passed element is a composite element and has no host children or has more than one host child.
|
|
67
|
-
* @returns If the passed element is a host element, it will return itself, if the passed element is a composite
|
|
68
|
-
* element, it will return a single host descendant.
|
|
69
|
-
*/
|
|
70
|
-
function getHostSelf(element) {
|
|
71
|
-
const hostSelves = getHostSelves(element);
|
|
72
|
-
if (hostSelves.length === 0) {
|
|
73
|
-
throw new Error(`Expected exactly one host element, but found none.`);
|
|
74
|
-
}
|
|
75
|
-
if (hostSelves.length > 1) {
|
|
76
|
-
throw new Error(`Expected exactly one host element, but found ${hostSelves.length}.`);
|
|
77
|
-
}
|
|
78
|
-
return hostSelves[0];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
59
|
/**
|
|
82
60
|
* Return the array of host elements that represent the passed element.
|
|
83
61
|
*
|
|
@@ -98,27 +76,4 @@ function getHostSiblings(element) {
|
|
|
98
76
|
const hostSelves = getHostSelves(element);
|
|
99
77
|
return getHostChildren(hostParent).filter(sibling => !hostSelves.includes(sibling));
|
|
100
78
|
}
|
|
101
|
-
function getCompositeParentOfType(element, type) {
|
|
102
|
-
let current = element.parent;
|
|
103
|
-
while (!isHostElement(current)) {
|
|
104
|
-
// We're at the root of the tree
|
|
105
|
-
if (!current) {
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
if (current.type === type) {
|
|
109
|
-
return current;
|
|
110
|
-
}
|
|
111
|
-
current = current.parent;
|
|
112
|
-
}
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Note: this function should be generally used for core React Native types like `View`, `Text`, `TextInput`, etc.
|
|
118
|
-
*/
|
|
119
|
-
function isHostElementForType(element, type) {
|
|
120
|
-
// Not a host element
|
|
121
|
-
if (!isHostElement(element)) return false;
|
|
122
|
-
return getCompositeParentOfType(element, type) !== null;
|
|
123
|
-
}
|
|
124
79
|
//# sourceMappingURL=component-tree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-tree.js","names":["isHostElement","element","type","getHostParent","current","parent","getHostChildren","hostChildren","children","forEach","child","push","
|
|
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) {\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,aAAaA,CAACC,OAAkC,EAAE;EAChE,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ;AAC1C;;AAEA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CAC3BF,OAAiC,EACP;EAC1B,IAAIA,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,IAAI;EACb;EAEA,IAAIG,OAAO,GAAGH,OAAO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|
|
6
6
|
exports.deprecateQueries = deprecateQueries;
|
|
7
|
+
exports.printDeprecationWarning = printDeprecationWarning;
|
|
7
8
|
var _queryName = require("./query-name");
|
|
8
9
|
function deprecateQueries(queriesObject, recommendation) {
|
|
9
10
|
const result = {};
|
|
@@ -26,4 +27,19 @@ function deprecateQuery(queryFn, queryName, recommendation) {
|
|
|
26
27
|
};
|
|
27
28
|
return wrapper;
|
|
28
29
|
}
|
|
30
|
+
const warned = {};
|
|
31
|
+
|
|
32
|
+
// istambul ignore next: Occasionally used
|
|
33
|
+
function printDeprecationWarning(functionName) {
|
|
34
|
+
if (warned[functionName]) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// eslint-disable-next-line no-console
|
|
39
|
+
console.warn(`
|
|
40
|
+
Deprecation Warning:
|
|
41
|
+
Use of ${functionName} is not recommended and will be deleted in future versions of @testing-library/react-native.
|
|
42
|
+
`);
|
|
43
|
+
warned[functionName] = true;
|
|
44
|
+
}
|
|
29
45
|
//# sourceMappingURL=deprecation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deprecation.js","names":["_queryName","require","deprecateQueries","queriesObject","recommendation","result","Object","keys","forEach","queryName","queryFn","deprecateQuery","formattedRecommendation","replace","getQueryPrefix","wrapper","args","errorMessage","console","warn"],"sources":["../../src/helpers/deprecation.ts"],"sourcesContent":["import { getQueryPrefix } from './query-name';\n\nexport function deprecateQueries<Queries extends Record<string, any>>(\n queriesObject: Queries,\n recommendation: string\n): Queries {\n const result = {} as Queries;\n Object.keys(queriesObject).forEach((queryName) => {\n const queryFn = queriesObject[queryName];\n // @ts-expect-error: generic typing is hard\n result[queryName] = deprecateQuery(queryFn, queryName, recommendation);\n });\n\n return result;\n}\n\nfunction deprecateQuery<QueryFn extends (...args: any) => any>(\n queryFn: QueryFn,\n queryName: string,\n recommendation: string\n): QueryFn {\n const formattedRecommendation = recommendation.replace(\n /{queryPrefix}/g,\n getQueryPrefix(queryName)\n );\n\n // @ts-expect-error: generic typing is hard\n const wrapper: QueryFn = (...args: any) => {\n const errorMessage = `${queryName}(...) is deprecated and will be removed in the future.\\n\\n${formattedRecommendation}`;\n // eslint-disable-next-line no-console\n console.warn(errorMessage);\n return queryFn(...args);\n };\n\n return wrapper;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"deprecation.js","names":["_queryName","require","deprecateQueries","queriesObject","recommendation","result","Object","keys","forEach","queryName","queryFn","deprecateQuery","formattedRecommendation","replace","getQueryPrefix","wrapper","args","errorMessage","console","warn","warned","printDeprecationWarning","functionName"],"sources":["../../src/helpers/deprecation.ts"],"sourcesContent":["import { getQueryPrefix } from './query-name';\n\nexport function deprecateQueries<Queries extends Record<string, any>>(\n queriesObject: Queries,\n recommendation: string\n): Queries {\n const result = {} as Queries;\n Object.keys(queriesObject).forEach((queryName) => {\n const queryFn = queriesObject[queryName];\n // @ts-expect-error: generic typing is hard\n result[queryName] = deprecateQuery(queryFn, queryName, recommendation);\n });\n\n return result;\n}\n\nfunction deprecateQuery<QueryFn extends (...args: any) => any>(\n queryFn: QueryFn,\n queryName: string,\n recommendation: string\n): QueryFn {\n const formattedRecommendation = recommendation.replace(\n /{queryPrefix}/g,\n getQueryPrefix(queryName)\n );\n\n // @ts-expect-error: generic typing is hard\n const wrapper: QueryFn = (...args: any) => {\n const errorMessage = `${queryName}(...) is deprecated and will be removed in the future.\\n\\n${formattedRecommendation}`;\n // eslint-disable-next-line no-console\n console.warn(errorMessage);\n return queryFn(...args);\n };\n\n return wrapper;\n}\n\nconst warned: { [functionName: string]: boolean } = {};\n\n// istambul ignore next: Occasionally used\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"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEO,SAASC,gBAAgBA,CAC9BC,aAAsB,EACtBC,cAAsB,EACb;EACT,MAAMC,MAAM,GAAG,CAAC,CAAY;EAC5BC,MAAM,CAACC,IAAI,CAACJ,aAAa,CAAC,CAACK,OAAO,CAAEC,SAAS,IAAK;IAChD,MAAMC,OAAO,GAAGP,aAAa,CAACM,SAAS,CAAC;IACxC;IACAJ,MAAM,CAACI,SAAS,CAAC,GAAGE,cAAc,CAACD,OAAO,EAAED,SAAS,EAAEL,cAAc,CAAC;EACxE,CAAC,CAAC;EAEF,OAAOC,MAAM;AACf;AAEA,SAASM,cAAcA,CACrBD,OAAgB,EAChBD,SAAiB,EACjBL,cAAsB,EACb;EACT,MAAMQ,uBAAuB,GAAGR,cAAc,CAACS,OAAO,CACpD,gBAAgB,EAChB,IAAAC,yBAAc,EAACL,SAAS,CAC1B,CAAC;;EAED;EACA,MAAMM,OAAgB,GAAGA,CAAC,GAAGC,IAAS,KAAK;IACzC,MAAMC,YAAY,GAAI,GAAER,SAAU,6DAA4DG,uBAAwB,EAAC;IACvH;IACAM,OAAO,CAACC,IAAI,CAACF,YAAY,CAAC;IAC1B,OAAOP,OAAO,CAAC,GAAGM,IAAI,CAAC;EACzB,CAAC;EAED,OAAOD,OAAO;AAChB;AAEA,MAAMK,MAA2C,GAAG,CAAC,CAAC;;AAEtD;AACO,SAASC,uBAAuBA,CAACC,YAAoB,EAAE;EAC5D,IAAIF,MAAM,CAACE,YAAY,CAAC,EAAE;IACxB;EACF;;EAEA;EACAJ,OAAO,CAACC,IAAI,CAAE;AAChB;AACA,WAAWG,YAAa;AACxB,GAAG,CAAC;EAEFF,MAAM,CAACE,YAAY,CAAC,GAAG,IAAI;AAC7B"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
export declare class ErrorWithStack extends Error {
|
|
2
2
|
constructor(message: string | undefined, callsite: Function);
|
|
3
3
|
}
|
|
4
|
-
export declare const createLibraryNotSupportedError: (error: unknown) => Error;
|
|
5
4
|
export declare const prepareErrorMessage: (error: unknown, name?: string, value?: unknown) => string;
|
|
6
5
|
export declare const createQueryByError: (error: unknown, callsite: Function) => null;
|
|
7
6
|
export declare function copyStackTrace(target: unknown, stackTraceSource: Error): void;
|
|
8
|
-
export declare function printDeprecationWarning(functionName: string): void;
|
|
9
|
-
export declare function throwRemovedFunctionError(functionName: string, docsRef: string): void;
|
|
10
|
-
export declare function throwRenamedFunctionError(functionName: string, newFunctionName: string): void;
|
package/build/helpers/errors.js
CHANGED
|
@@ -5,10 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.ErrorWithStack = void 0;
|
|
7
7
|
exports.copyStackTrace = copyStackTrace;
|
|
8
|
-
exports.prepareErrorMessage = exports.createQueryByError =
|
|
9
|
-
exports.printDeprecationWarning = printDeprecationWarning;
|
|
10
|
-
exports.throwRemovedFunctionError = throwRemovedFunctionError;
|
|
11
|
-
exports.throwRenamedFunctionError = throwRenamedFunctionError;
|
|
8
|
+
exports.prepareErrorMessage = exports.createQueryByError = void 0;
|
|
12
9
|
var _prettyFormat = _interopRequireDefault(require("pretty-format"));
|
|
13
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
11
|
class ErrorWithStack extends Error {
|
|
@@ -20,8 +17,6 @@ class ErrorWithStack extends Error {
|
|
|
20
17
|
}
|
|
21
18
|
}
|
|
22
19
|
exports.ErrorWithStack = ErrorWithStack;
|
|
23
|
-
const createLibraryNotSupportedError = error => new Error(`Currently the only supported library to search by text is "react-native".\n\n${error instanceof Error ? error.message : ''}`);
|
|
24
|
-
exports.createLibraryNotSupportedError = createLibraryNotSupportedError;
|
|
25
20
|
const prepareErrorMessage = (error, name, value) => {
|
|
26
21
|
let errorMessage;
|
|
27
22
|
if (error instanceof Error) {
|
|
@@ -58,23 +53,4 @@ function copyStackTrace(target, stackTraceSource) {
|
|
|
58
53
|
target.stack = stackTraceSource.stack.replace(stackTraceSource.message, target.message);
|
|
59
54
|
}
|
|
60
55
|
}
|
|
61
|
-
const warned = {};
|
|
62
|
-
function printDeprecationWarning(functionName) {
|
|
63
|
-
if (warned[functionName]) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// eslint-disable-next-line no-console
|
|
68
|
-
console.warn(`
|
|
69
|
-
Deprecation Warning:
|
|
70
|
-
Use of ${functionName} is not recommended and will be deleted in future versions of @testing-library/react-native.
|
|
71
|
-
`);
|
|
72
|
-
warned[functionName] = true;
|
|
73
|
-
}
|
|
74
|
-
function throwRemovedFunctionError(functionName, docsRef) {
|
|
75
|
-
throw new Error(`"${functionName}" has been removed.\n\nPlease consult: https://callstack.github.io/react-native-testing-library/docs/${docsRef}`);
|
|
76
|
-
}
|
|
77
|
-
function throwRenamedFunctionError(functionName, newFunctionName) {
|
|
78
|
-
throw new ErrorWithStack(`The "${functionName}" function has been renamed to "${newFunctionName}". Please replace all occurrences.`, throwRenamedFunctionError);
|
|
79
|
-
}
|
|
80
56
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":["_prettyFormat","_interopRequireDefault","require","obj","__esModule","default","ErrorWithStack","Error","constructor","message","callsite","captureStackTrace","exports","
|
|
1
|
+
{"version":3,"file":"errors.js","names":["_prettyFormat","_interopRequireDefault","require","obj","__esModule","default","ErrorWithStack","Error","constructor","message","callsite","captureStackTrace","exports","prepareErrorMessage","error","name","value","errorMessage","replace","toString","prettyFormat","min","createQueryByError","includes","copyStackTrace","target","stackTraceSource","stack"],"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 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"],"mappings":";;;;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAyC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAElC,MAAMG,cAAc,SAASC,KAAK,CAAC;EACxCC,WAAWA,CAACC,OAA2B,EAAEC,QAAkB,EAAE;IAC3D,KAAK,CAACD,OAAO,CAAC;IACd,IAAIF,KAAK,CAACI,iBAAiB,EAAE;MAC3BJ,KAAK,CAACI,iBAAiB,CAAC,IAAI,EAAED,QAAQ,CAAC;IACzC;EACF;AACF;AAACE,OAAA,CAAAN,cAAA,GAAAA,cAAA;AAEM,MAAMO,mBAAmB,GAAGA,CAGjCC,KAAc,EACdC,IAAa,EACbC,KAAe,KACJ;EACX,IAAIC,YAAoB;EACxB,IAAIH,KAAK,YAAYP,KAAK,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|
1
|
-
{"version":3,"file":"findAll.js","names":["_config","require","_accessiblity","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":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAaO,SAASE,OAAOA,CACrBC,IAAuB,EACvBC,SAAkD,EAClDC,OAAwB,EACxB;EACA,MAAMC,OAAO,GAAGC,eAAe,CAACJ,IAAI,EAAEC,SAAS,EAAEC,OAAO,CAAC;EAEzD,MAAMG,qBAAqB,GACzBH,OAAO,EAAEG,qBAAqB,IAC9BH,OAAO,EAAEI,MAAM,IACf,IAAAC,iBAAS,
|
|
1
|
+
{"version":3,"file":"findAll.js","names":["_config","require","_accessiblity","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":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAaO,SAASE,OAAOA,CACrBC,IAAuB,EACvBC,SAAkD,EAClDC,OAAwB,EACxB;EACA,MAAMC,OAAO,GAAGC,eAAe,CAACJ,IAAI,EAAEC,SAAS,EAAEC,OAAO,CAAC;EAEzD,MAAMG,qBAAqB,GACzBH,OAAO,EAAEG,qBAAqB,IAC9BH,OAAO,EAAEI,MAAM,IACf,IAAAC,iBAAS,EAAC,CAAC,EAAEC,4BAA4B;EAE3C,IAAIH,qBAAqB,EAAE;IACzB,OAAOF,OAAO;EAChB;EAEA,MAAMM,KAAK,GAAG,IAAIC,OAAO,CAAoB,CAAC;EAC9C,OAAOP,OAAO,CAACQ,MAAM,CAClBC,OAAO,IAAK,CAAC,IAAAC,uCAAyB,EAACD,OAAO,EAAE;IAAEH;EAAM,CAAC,CAC5D,CAAC;AACH;;AAEA;AACA;AACA,SAASL,eAAeA,CACtBJ,IAAuB,EACvBC,SAAkD,EAClDC,OAAwB,EACE;EAC1B,MAAMC,OAA4B,GAAG,EAAE;;EAEvC;EACA,MAAMW,mBAAwC,GAAG,EAAE;EACnDd,IAAI,CAACe,QAAQ,CAACC,OAAO,CAAEC,KAAK,IAAK;IAC/B,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC7B;IACF;IACAH,mBAAmB,CAACI,IAAI,CAAC,GAAGd,eAAe,CAACa,KAAK,EAAEhB,SAAS,EAAEC,OAAO,CAAC,CAAC;EACzE,CAAC,CAAC;EAEF;EACE;EACA,CAAC,CAACA,OAAO,EAAEiB,gBAAgB,IAAIL,mBAAmB,CAACM,MAAM,KAAK,CAAC,KAC/DnB,SAAS,CAACD,IAAI,CAAC,EACf;IACAG,OAAO,CAACe,IAAI,CAAClB,IAAI,CAAC;EACpB;;EAEA;EACAG,OAAO,CAACe,IAAI,CAAC,GAAGJ,mBAAmB,CAAC;EAEpC,OAAOX,OAAO;AAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-default.js","names":["_reactNative","require","propsToDisplay","defaultMapProps","props","result","styles","StyleSheet","flatten","style","display","accessibilityState","removeUndefinedKeys","undefined","accessibilityValue","forEach","propName","exports","isObject","value","Array","isArray","prop","Object","entries","key","keys","length"],"sources":["../../src/helpers/format-default.ts"],"sourcesContent":["import { StyleSheet, ViewStyle } from 'react-native';\nimport { MapPropsFunction } from './format';\n\nconst propsToDisplay = [\n 'testID',\n 'nativeID',\n 'accessibilityElementsHidden',\n 'accessibilityViewIsModal',\n 'importantForAccessibility',\n 'accessibilityRole',\n 'accessibilityLabel',\n 'accessibilityLabelledBy',\n 'accessibilityHint',\n 'placeholder',\n 'value',\n 'defaultValue',\n 'title',\n];\n\n/**\n * Preserve props that are helpful in diagnosing test failures, while stripping rest\n */\nexport const defaultMapProps: MapPropsFunction = (props) => {\n const result: Record<string, unknown> = {};\n\n const styles = StyleSheet.flatten(props.style as ViewStyle);\n if (styles?.display === 'none') {\n result.style = { display: 'none' };\n }\n\n const accessibilityState = removeUndefinedKeys(props.accessibilityState);\n if (accessibilityState !== undefined) {\n result.accessibilityState = accessibilityState;\n }\n\n const accessibilityValue = removeUndefinedKeys(props.accessibilityValue);\n if (accessibilityValue !== undefined) {\n result.accessibilityValue = accessibilityValue;\n }\n\n propsToDisplay.forEach((propName) => {\n if (propName in props) {\n result[propName] = props[propName];\n }\n });\n\n return result;\n};\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction removeUndefinedKeys(prop: unknown) {\n if (!isObject(prop)) {\n return prop;\n }\n\n const result: Record<string, unknown> = {};\n Object.entries(prop).forEach(([key, value]) => {\n if (value !== undefined) {\n result[key] = value;\n }\n });\n\n // If object does not have any props we will ignore it.\n if (Object.keys(result).length === 0) {\n return undefined;\n }\n\n return result;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA,MAAMC,cAAc,GAAG,CACrB,QAAQ,EACR,UAAU,EACV,6BAA6B,EAC7B,0BAA0B,EAC1B,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EACb,OAAO,EACP,cAAc,EACd,OAAO,CACR;;AAED;AACA;AACA;AACO,MAAMC,eAAiC,GAAIC,KAAK,IAAK;EAC1D,MAAMC,MAA+B,GAAG,CAAC,CAAC;EAE1C,MAAMC,MAAM,GAAGC,uBAAU,CAACC,OAAO,CAACJ,KAAK,CAACK,
|
|
1
|
+
{"version":3,"file":"format-default.js","names":["_reactNative","require","propsToDisplay","defaultMapProps","props","result","styles","StyleSheet","flatten","style","display","accessibilityState","removeUndefinedKeys","undefined","accessibilityValue","forEach","propName","exports","isObject","value","Array","isArray","prop","Object","entries","key","keys","length"],"sources":["../../src/helpers/format-default.ts"],"sourcesContent":["import { StyleSheet, ViewStyle } from 'react-native';\nimport { MapPropsFunction } from './format';\n\nconst propsToDisplay = [\n 'testID',\n 'nativeID',\n 'accessibilityElementsHidden',\n 'accessibilityViewIsModal',\n 'importantForAccessibility',\n 'accessibilityRole',\n 'accessibilityLabel',\n 'accessibilityLabelledBy',\n 'accessibilityHint',\n 'placeholder',\n 'value',\n 'defaultValue',\n 'title',\n];\n\n/**\n * Preserve props that are helpful in diagnosing test failures, while stripping rest\n */\nexport const defaultMapProps: MapPropsFunction = (props) => {\n const result: Record<string, unknown> = {};\n\n const styles = StyleSheet.flatten(props.style as ViewStyle);\n if (styles?.display === 'none') {\n result.style = { display: 'none' };\n }\n\n const accessibilityState = removeUndefinedKeys(props.accessibilityState);\n if (accessibilityState !== undefined) {\n result.accessibilityState = accessibilityState;\n }\n\n const accessibilityValue = removeUndefinedKeys(props.accessibilityValue);\n if (accessibilityValue !== undefined) {\n result.accessibilityValue = accessibilityValue;\n }\n\n propsToDisplay.forEach((propName) => {\n if (propName in props) {\n result[propName] = props[propName];\n }\n });\n\n return result;\n};\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction removeUndefinedKeys(prop: unknown) {\n if (!isObject(prop)) {\n return prop;\n }\n\n const result: Record<string, unknown> = {};\n Object.entries(prop).forEach(([key, value]) => {\n if (value !== undefined) {\n result[key] = value;\n }\n });\n\n // If object does not have any props we will ignore it.\n if (Object.keys(result).length === 0) {\n return undefined;\n }\n\n return result;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA,MAAMC,cAAc,GAAG,CACrB,QAAQ,EACR,UAAU,EACV,6BAA6B,EAC7B,0BAA0B,EAC1B,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EACb,OAAO,EACP,cAAc,EACd,OAAO,CACR;;AAED;AACA;AACA;AACO,MAAMC,eAAiC,GAAIC,KAAK,IAAK;EAC1D,MAAMC,MAA+B,GAAG,CAAC,CAAC;EAE1C,MAAMC,MAAM,GAAGC,uBAAU,CAACC,OAAO,CAACJ,KAAK,CAACK,KAAkB,CAAC;EAC3D,IAAIH,MAAM,EAAEI,OAAO,KAAK,MAAM,EAAE;IAC9BL,MAAM,CAACI,KAAK,GAAG;MAAEC,OAAO,EAAE;IAAO,CAAC;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ACf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","names":["_prettyFormat","_interopRequireWildcard","require","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","format","input","options","prettyFormat","plugins","getCustomPlugin","mapProps","ReactElement","highlight","shouldHighlight","printBasicPrototype","test","val","ReactTestComponent","serialize","config","indentation","depth","refs","printer","newVal","props","process","env","COLORS","_default","exports"],"sources":["../../src/helpers/format.ts"],"sourcesContent":["import type { ReactTestRendererJSON } from 'react-test-renderer';\nimport prettyFormat, { NewPlugin, plugins } from 'pretty-format';\n\nexport type MapPropsFunction = (\n props: Record<string, unknown>,\n node: ReactTestRendererJSON\n) => Record<string, unknown>;\n\nexport type FormatOptions = {\n mapProps?: MapPropsFunction;\n};\n\nconst format = (\n input: ReactTestRendererJSON | ReactTestRendererJSON[],\n options: FormatOptions = {}\n) =>\n prettyFormat(input, {\n plugins: [getCustomPlugin(options.mapProps), plugins.ReactElement],\n highlight: shouldHighlight(),\n printBasicPrototype: false,\n });\n\nconst getCustomPlugin = (mapProps?: MapPropsFunction): NewPlugin => {\n return {\n test: (val) => plugins.ReactTestComponent.test(val),\n serialize: (val, config, indentation, depth, refs, printer) => {\n let newVal = val;\n if (mapProps && val.props) {\n newVal = { ...val, props: mapProps(val.props, val) };\n }\n return plugins.ReactTestComponent.serialize(\n newVal,\n config,\n indentation,\n depth,\n refs,\n printer\n );\n },\n };\n};\n\nfunction shouldHighlight() {\n return process?.env?.COLORS !== 'false';\n}\n\nexport default format;\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAiE,SAAAC,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAA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":"format.js","names":["_prettyFormat","_interopRequireWildcard","require","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","format","input","options","prettyFormat","plugins","getCustomPlugin","mapProps","ReactElement","highlight","shouldHighlight","printBasicPrototype","test","val","ReactTestComponent","serialize","config","indentation","depth","refs","printer","newVal","props","process","env","COLORS","_default","exports"],"sources":["../../src/helpers/format.ts"],"sourcesContent":["import type { ReactTestRendererJSON } from 'react-test-renderer';\nimport prettyFormat, { NewPlugin, plugins } from 'pretty-format';\n\nexport type MapPropsFunction = (\n props: Record<string, unknown>,\n node: ReactTestRendererJSON\n) => Record<string, unknown>;\n\nexport type FormatOptions = {\n mapProps?: MapPropsFunction;\n};\n\nconst format = (\n input: ReactTestRendererJSON | ReactTestRendererJSON[],\n options: FormatOptions = {}\n) =>\n prettyFormat(input, {\n plugins: [getCustomPlugin(options.mapProps), plugins.ReactElement],\n highlight: shouldHighlight(),\n printBasicPrototype: false,\n });\n\nconst getCustomPlugin = (mapProps?: MapPropsFunction): NewPlugin => {\n return {\n test: (val) => plugins.ReactTestComponent.test(val),\n serialize: (val, config, indentation, depth, refs, printer) => {\n let newVal = val;\n if (mapProps && val.props) {\n newVal = { ...val, props: mapProps(val.props, val) };\n }\n return plugins.ReactTestComponent.serialize(\n newVal,\n config,\n indentation,\n depth,\n refs,\n printer\n );\n },\n };\n};\n\nfunction shouldHighlight() {\n return process?.env?.COLORS !== 'false';\n}\n\nexport default format;\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAiE,SAAAC,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD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GAAIC,QAA2B,IAAgB;EAClE,OAAO;IACLK,IAAI,EAAGC,GAAG,IAAKR,qBAAO,CAACS,kBAAkB,CAACF,IAAI,CAACC,GAAG,CAAC;IACnDE,SAAS,EAAEA,CAACF,GAAG,EAAEG,MAAM,EAAEC,WAAW,EAAEC,KAAK,EAAEC,IAAI,EAAEC,OAAO,KAAK;MAC7D,IAAIC,MAAM,GAAGR,GAAG;MAChB,IAAIN,QAAQ,IAAIM,GAAG,CAACS,KAAK,EAAE;QACzBD,MAAM,GAAG;UAAE,GAAGR,GAAG;UAAES,KAAK,EAAEf,QAAQ,CAACM,GAAG,CAACS,KAAK,EAAET,GAAG;QAAE,CAAC;MACtD;MACA,OAAOR,qBAAO,CAACS,kBAAkB,CAACC,SAAS,CACzCM,MAAM,EACNL,MAAM,EACNC,WAAW,EACXC,KAAK,EACLC,IAAI,EACJC,OACF,CAAC;IACH;EACF,CAAC;AACH,CAAC;AAED,SAASV,eAAeA,CAAA,EAAG;EACzB,OAAOa,OAAO,EAAEC,GAAG,EAAEC,MAAM,KAAK,OAAO;AACzC;AAAC,IAAAC,QAAA,GAEczB,MAAM;AAAA0B,OAAA,CAAAzC,OAAA,GAAAwC,QAAA"}
|
|
@@ -39,10 +39,13 @@ function detectHostComponentNames() {
|
|
|
39
39
|
testID: "text"
|
|
40
40
|
}, "Hello"), /*#__PURE__*/React.createElement(_reactNative.TextInput, {
|
|
41
41
|
testID: "textInput"
|
|
42
|
+
}), /*#__PURE__*/React.createElement(_reactNative.Switch, {
|
|
43
|
+
testID: "switch"
|
|
42
44
|
})));
|
|
43
45
|
return {
|
|
44
46
|
text: getByTestId(renderer.root, 'text').type,
|
|
45
|
-
textInput: getByTestId(renderer.root, 'textInput').type
|
|
47
|
+
textInput: getByTestId(renderer.root, 'textInput').type,
|
|
48
|
+
switch: getByTestId(renderer.root, 'switch').type
|
|
46
49
|
};
|
|
47
50
|
} catch (error) {
|
|
48
51
|
const errorMessage = error && typeof error === 'object' && 'message' in error ? error.message : null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-component-names.js","names":["React","_interopRequireWildcard","require","_reactNative","_config","_renderAct","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","userConfigErrorMessage","getHostComponentNames","hostComponentNames","getConfig","detectHostComponentNames","configureInternal","configureHostComponentNamesIfNeeded","configHostComponentNames","renderer","renderWithAct","createElement","View","Text","testID","TextInput","text","getByTestId","root","type","textInput","error","errorMessage","message","Error","instance","nodes","findAll","node","props","length"],"sources":["../../src/helpers/host-component-names.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { Text, TextInput, View } from 'react-native';\nimport { configureInternal, getConfig, HostComponentNames } from '../config';\nimport { renderWithAct } from '../render-act';\n\nconst userConfigErrorMessage = `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 let hostComponentNames = getConfig().hostComponentNames;\n if (!hostComponentNames) {\n hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n }\n\n return hostComponentNames;\n}\n\nexport function configureHostComponentNamesIfNeeded() {\n const configHostComponentNames = getConfig().hostComponentNames;\n if (configHostComponentNames) {\n return;\n }\n\n const hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n}\n\nfunction detectHostComponentNames(): HostComponentNames {\n try {\n const renderer = renderWithAct(\n <View>\n <Text testID=\"text\">Hello</Text>\n <TextInput testID=\"textInput\" />\n </View>\n );\n\n return {\n text: getByTestId(renderer.root, 'text').type as string,\n textInput: getByTestId(renderer.root, 'textInput').type as string,\n };\n } catch (error) {\n const errorMessage =\n error && typeof error === 'object' && 'message' in error\n ? error.message\n : null;\n\n throw new Error(\n `Trying to detect host component names triggered the following error:\\n\\n${errorMessage}\\n\\n${userConfigErrorMessage}`\n );\n }\n}\n\nfunction getByTestId(instance: ReactTestInstance, testID: string) {\n const nodes = instance.findAll(\n (node) => typeof node.type === 'string' && node.props.testID === testID\n );\n\n if (nodes.length === 0) {\n throw new Error(`Unable to find an element with testID: ${testID}`);\n }\n\n return nodes[0];\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAA8C,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAN,wBAAAU,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA;AAE9C,MAAMW,sBAAsB,GAAI;AAChC,oGAAoG;AAE7F,SAASC,qBAAqBA,CAAA,EAAuB;EAC1D,IAAIC,kBAAkB,GAAG,IAAAC,iBAAS,
|
|
1
|
+
{"version":3,"file":"host-component-names.js","names":["React","_interopRequireWildcard","require","_reactNative","_config","_renderAct","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","userConfigErrorMessage","getHostComponentNames","hostComponentNames","getConfig","detectHostComponentNames","configureInternal","configureHostComponentNamesIfNeeded","configHostComponentNames","renderer","renderWithAct","createElement","View","Text","testID","TextInput","Switch","text","getByTestId","root","type","textInput","switch","error","errorMessage","message","Error","instance","nodes","findAll","node","props","length"],"sources":["../../src/helpers/host-component-names.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { Switch, Text, TextInput, View } from 'react-native';\nimport { configureInternal, getConfig, HostComponentNames } from '../config';\nimport { renderWithAct } from '../render-act';\n\nconst userConfigErrorMessage = `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 let hostComponentNames = getConfig().hostComponentNames;\n if (!hostComponentNames) {\n hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n }\n\n return hostComponentNames;\n}\n\nexport function configureHostComponentNamesIfNeeded() {\n const configHostComponentNames = getConfig().hostComponentNames;\n if (configHostComponentNames) {\n return;\n }\n\n const hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n}\n\nfunction detectHostComponentNames(): HostComponentNames {\n try {\n const renderer = renderWithAct(\n <View>\n <Text testID=\"text\">Hello</Text>\n <TextInput testID=\"textInput\" />\n <Switch testID=\"switch\" />\n </View>\n );\n\n return {\n text: getByTestId(renderer.root, 'text').type as string,\n textInput: getByTestId(renderer.root, 'textInput').type as string,\n switch: getByTestId(renderer.root, 'switch').type as string,\n };\n } catch (error) {\n const errorMessage =\n error && typeof error === 'object' && 'message' in error\n ? error.message\n : null;\n\n throw new Error(\n `Trying to detect host component names triggered the following error:\\n\\n${errorMessage}\\n\\n${userConfigErrorMessage}`\n );\n }\n}\n\nfunction getByTestId(instance: ReactTestInstance, testID: string) {\n const nodes = instance.findAll(\n (node) => typeof node.type === 'string' && node.props.testID === testID\n );\n\n if (nodes.length === 0) {\n throw new Error(`Unable to find an element with testID: ${testID}`);\n }\n\n return nodes[0];\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAA8C,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAN,wBAAAU,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA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,MAAM,IAAIN,KAAK,CAAE,0CAAyCZ,MAAO,EAAC,CAAC;EACrE;EAEA,OAAOc,KAAK,CAAC,CAAC,CAAC;AACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchLabelText.js","names":["_matches","require","_findAll","_matchTextContent","matchLabelText","root","element","text","options","matchAccessibilityLabel","matchAccessibilityLabelledBy","props","accessibilityLabelledBy","exact","normalizer","matches","accessibilityLabel","nativeId","findAll","node","type","nativeID","matchTextContent","length"],"sources":["../../../src/helpers/matchers/matchLabelText.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matches, TextMatch, TextMatchOptions } from '../../matches';\nimport { findAll } from '../findAll';\nimport { matchTextContent } from './matchTextContent';\n\nexport function matchLabelText(\n root: ReactTestInstance,\n element: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) {\n return (\n matchAccessibilityLabel(element, text, options) ||\n matchAccessibilityLabelledBy(\n root,\n element.props.accessibilityLabelledBy,\n text,\n options\n )\n );\n}\n\nfunction matchAccessibilityLabel(\n element: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions\n) {\n const { exact, normalizer } = options;\n return matches(text, element.props.accessibilityLabel, normalizer, exact);\n}\n\nfunction matchAccessibilityLabelledBy(\n root: ReactTestInstance,\n nativeId: string | undefined,\n text: TextMatch,\n options: TextMatchOptions\n) {\n if (!nativeId) {\n return false;\n }\n\n return (\n findAll(\n root,\n (node) =>\n typeof node.type === 'string' &&\n node.props.nativeID === nativeId &&\n matchTextContent(node, text, options)\n ).length > 0\n );\n}\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEO,SAASG,cAAcA,CAC5BC,IAAuB,EACvBC,OAA0B,EAC1BC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,EAC9B;EACA,OACEC,uBAAuB,CAACH,OAAO,EAAEC,IAAI,EAAEC,OAAO,CAAC,IAC/CE,4BAA4B,CAC1BL,IAAI,EACJC,OAAO,CAACK,KAAK,CAACC,uBAAuB,EACrCL,IAAI,EACJC,
|
|
1
|
+
{"version":3,"file":"matchLabelText.js","names":["_matches","require","_findAll","_matchTextContent","matchLabelText","root","element","text","options","matchAccessibilityLabel","matchAccessibilityLabelledBy","props","accessibilityLabelledBy","exact","normalizer","matches","accessibilityLabel","nativeId","findAll","node","type","nativeID","matchTextContent","length"],"sources":["../../../src/helpers/matchers/matchLabelText.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matches, TextMatch, TextMatchOptions } from '../../matches';\nimport { findAll } from '../findAll';\nimport { matchTextContent } from './matchTextContent';\n\nexport function matchLabelText(\n root: ReactTestInstance,\n element: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) {\n return (\n matchAccessibilityLabel(element, text, options) ||\n matchAccessibilityLabelledBy(\n root,\n element.props.accessibilityLabelledBy,\n text,\n options\n )\n );\n}\n\nfunction matchAccessibilityLabel(\n element: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions\n) {\n const { exact, normalizer } = options;\n return matches(text, element.props.accessibilityLabel, normalizer, exact);\n}\n\nfunction matchAccessibilityLabelledBy(\n root: ReactTestInstance,\n nativeId: string | undefined,\n text: TextMatch,\n options: TextMatchOptions\n) {\n if (!nativeId) {\n return false;\n }\n\n return (\n findAll(\n root,\n (node) =>\n typeof node.type === 'string' &&\n node.props.nativeID === nativeId &&\n matchTextContent(node, text, options)\n ).length > 0\n );\n}\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEO,SAASG,cAAcA,CAC5BC,IAAuB,EACvBC,OAA0B,EAC1BC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,EAC9B;EACA,OACEC,uBAAuB,CAACH,OAAO,EAAEC,IAAI,EAAEC,OAAO,CAAC,IAC/CE,4BAA4B,CAC1BL,IAAI,EACJC,OAAO,CAACK,KAAK,CAACC,uBAAuB,EACrCL,IAAI,EACJC,OACF,CAAC;AAEL;AAEA,SAASC,uBAAuBA,CAC9BH,OAA0B,EAC1BC,IAAe,EACfC,OAAyB,EACzB;EACA,MAAM;IAAEK,KAAK;IAAEC;EAAW,CAAC,GAAGN,OAAO;EACrC,OAAO,IAAAO,gBAAO,EAACR,IAAI,EAAED,OAAO,CAACK,KAAK,CAACK,kBAAkB,EAAEF,UAAU,EAAED,KAAK,CAAC;AAC3E;AAEA,SAASH,4BAA4BA,CACnCL,IAAuB,EACvBY,QAA4B,EAC5BV,IAAe,EACfC,OAAyB,EACzB;EACA,IAAI,CAACS,QAAQ,EAAE;IACb,OAAO,KAAK;EACd;EAEA,OACE,IAAAC,gBAAO,EACLb,IAAI,EACHc,IAAI,IACH,OAAOA,IAAI,CAACC,IAAI,KAAK,QAAQ,IAC7BD,IAAI,CAACR,KAAK,CAACU,QAAQ,KAAKJ,QAAQ,IAChC,IAAAK,kCAAgB,EAACH,IAAI,EAAEZ,IAAI,EAAEC,OAAO,CACxC,CAAC,CAACe,MAAM,GAAG,CAAC;AAEhB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
+
/**
|
|
3
|
+
* pointerEvents controls whether the View can be the target of touch events.
|
|
4
|
+
* 'auto': The View and its children can be the target of touch events.
|
|
5
|
+
* 'none': The View is never the target of touch events.
|
|
6
|
+
* 'box-none': The View is never the target of touch events but its subviews can be
|
|
7
|
+
* 'box-only': The view can be the target of touch events but its subviews cannot be
|
|
8
|
+
* see the official react native doc https://reactnative.dev/docs/view#pointerevents */
|
|
9
|
+
export declare const isPointerEventEnabled: (element: ReactTestInstance, isParent?: boolean) => boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isPointerEventEnabled = void 0;
|
|
7
|
+
var _componentTree = require("./component-tree");
|
|
8
|
+
/**
|
|
9
|
+
* pointerEvents controls whether the View can be the target of touch events.
|
|
10
|
+
* 'auto': The View and its children can be the target of touch events.
|
|
11
|
+
* 'none': The View is never the target of touch events.
|
|
12
|
+
* 'box-none': The View is never the target of touch events but its subviews can be
|
|
13
|
+
* 'box-only': The view can be the target of touch events but its subviews cannot be
|
|
14
|
+
* see the official react native doc https://reactnative.dev/docs/view#pointerevents */
|
|
15
|
+
const isPointerEventEnabled = (element, isParent) => {
|
|
16
|
+
const parentCondition = isParent ? element?.props.pointerEvents === 'box-only' : element?.props.pointerEvents === 'box-none';
|
|
17
|
+
if (element?.props.pointerEvents === 'none' || parentCondition) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const hostParent = (0, _componentTree.getHostParent)(element);
|
|
21
|
+
if (!hostParent) return true;
|
|
22
|
+
return isPointerEventEnabled(hostParent, true);
|
|
23
|
+
};
|
|
24
|
+
exports.isPointerEventEnabled = isPointerEventEnabled;
|
|
25
|
+
//# sourceMappingURL=pointer-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer-events.js","names":["_componentTree","require","isPointerEventEnabled","element","isParent","parentCondition","props","pointerEvents","hostParent","getHostParent","exports"],"sources":["../../src/helpers/pointer-events.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { getHostParent } from './component-tree';\n\n/**\n * pointerEvents controls whether the View can be the target of touch events.\n * 'auto': The View and its children can be the target of touch events.\n * 'none': The View is never the target of touch events.\n * 'box-none': The View is never the target of touch events but its subviews can be\n * 'box-only': The view can be the target of touch events but its subviews cannot be\n * see the official react native doc https://reactnative.dev/docs/view#pointerevents */\nexport const 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 const hostParent = getHostParent(element);\n if (!hostParent) return true;\n\n return isPointerEventEnabled(hostParent, true);\n};\n"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,qBAAqB,GAAGA,CACnCC,OAA0B,EAC1BC,QAAkB,KACN;EACZ,MAAMC,eAAe,GAAGD,QAAQ,GAC5BD,OAAO,EAAEG,KAAK,CAACC,aAAa,KAAK,UAAU,GAC3CJ,OAAO,EAAEG,KAAK,CAACC,aAAa,KAAK,UAAU;EAE/C,IAAIJ,OAAO,EAAEG,KAAK,CAACC,aAAa,KAAK,MAAM,IAAIF,eAAe,EAAE;IAC9D,OAAO,KAAK;EACd;EAEA,MAAMG,UAAU,GAAG,IAAAC,4BAAa,EAACN,OAAO,CAAC;EACzC,IAAI,CAACK,UAAU,EAAE,OAAO,IAAI;EAE5B,OAAON,qBAAqB,CAACM,UAAU,EAAE,IAAI,CAAC;AAChD,CAAC;AAACE,OAAA,CAAAR,qBAAA,GAAAA,qBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringValidation.js","names":["validateStringsRenderedWithinText","rendererJSON","Array","isArray","forEach","validateStringsRenderedWithinTextForNode","exports","node","type","children","child","Error"],"sources":["../../src/helpers/stringValidation.ts"],"sourcesContent":["import { ReactTestRendererNode } from 'react-test-renderer';\n\nexport const validateStringsRenderedWithinText = (\n rendererJSON: ReactTestRendererNode | Array<ReactTestRendererNode> | null\n) => {\n if (!rendererJSON) return;\n\n if (Array.isArray(rendererJSON)) {\n rendererJSON.forEach(validateStringsRenderedWithinTextForNode);\n return;\n }\n\n return validateStringsRenderedWithinTextForNode(rendererJSON);\n};\n\nconst validateStringsRenderedWithinTextForNode = (\n node: ReactTestRendererNode\n) => {\n if (typeof node === 'string') {\n return;\n }\n\n if (node.type !== 'Text') {\n node.children?.forEach((child) => {\n if (typeof child === 'string') {\n throw new Error(\n `Invariant Violation: Text strings must be rendered within a <Text> component. Detected attempt to render \"${child}\" string within a <${node.type}> component.`\n );\n }\n });\n }\n\n if (node.children) {\n node.children.forEach(validateStringsRenderedWithinTextForNode);\n }\n};\n"],"mappings":";;;;;;AAEO,MAAMA,iCAAiC,GAC5CC,YAAyE,IACtE;EACH,IAAI,CAACA,YAAY,EAAE;EAEnB,IAAIC,KAAK,CAACC,OAAO,CAACF,YAAY,CAAC,EAAE;IAC/BA,YAAY,CAACG,OAAO,CAACC,wCAAwC,CAAC;IAC9D;EACF;EAEA,OAAOA,wCAAwC,CAACJ,YAAY,CAAC;AAC/D,CAAC;AAACK,OAAA,CAAAN,iCAAA,GAAAA,iCAAA;AAEF,MAAMK,wCAAwC,GAC5CE,IAA2B,IACxB;EACH,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B;EACF;EAEA,IAAIA,IAAI,CAACC,IAAI,KAAK,MAAM,EAAE;IACxBD,IAAI,CAACE,QAAQ,EAAEL,OAAO,CAAEM,KAAK,IAAK;MAChC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;QAC7B,MAAM,IAAIC,KAAK,CACZ,6GAA4GD,KAAM,sBAAqBH,IAAI,CAACC,IAAK,
|
|
1
|
+
{"version":3,"file":"stringValidation.js","names":["validateStringsRenderedWithinText","rendererJSON","Array","isArray","forEach","validateStringsRenderedWithinTextForNode","exports","node","type","children","child","Error"],"sources":["../../src/helpers/stringValidation.ts"],"sourcesContent":["import { ReactTestRendererNode } from 'react-test-renderer';\n\nexport const validateStringsRenderedWithinText = (\n rendererJSON: ReactTestRendererNode | Array<ReactTestRendererNode> | null\n) => {\n if (!rendererJSON) return;\n\n if (Array.isArray(rendererJSON)) {\n rendererJSON.forEach(validateStringsRenderedWithinTextForNode);\n return;\n }\n\n return validateStringsRenderedWithinTextForNode(rendererJSON);\n};\n\nconst validateStringsRenderedWithinTextForNode = (\n node: ReactTestRendererNode\n) => {\n if (typeof node === 'string') {\n return;\n }\n\n if (node.type !== 'Text') {\n node.children?.forEach((child) => {\n if (typeof child === 'string') {\n throw new Error(\n `Invariant Violation: Text strings must be rendered within a <Text> component. Detected attempt to render \"${child}\" string within a <${node.type}> component.`\n );\n }\n });\n }\n\n if (node.children) {\n node.children.forEach(validateStringsRenderedWithinTextForNode);\n }\n};\n"],"mappings":";;;;;;AAEO,MAAMA,iCAAiC,GAC5CC,YAAyE,IACtE;EACH,IAAI,CAACA,YAAY,EAAE;EAEnB,IAAIC,KAAK,CAACC,OAAO,CAACF,YAAY,CAAC,EAAE;IAC/BA,YAAY,CAACG,OAAO,CAACC,wCAAwC,CAAC;IAC9D;EACF;EAEA,OAAOA,wCAAwC,CAACJ,YAAY,CAAC;AAC/D,CAAC;AAACK,OAAA,CAAAN,iCAAA,GAAAA,iCAAA;AAEF,MAAMK,wCAAwC,GAC5CE,IAA2B,IACxB;EACH,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B;EACF;EAEA,IAAIA,IAAI,CAACC,IAAI,KAAK,MAAM,EAAE;IACxBD,IAAI,CAACE,QAAQ,EAAEL,OAAO,CAAEM,KAAK,IAAK;MAChC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;QAC7B,MAAM,IAAIC,KAAK,CACZ,6GAA4GD,KAAM,sBAAqBH,IAAI,CAACC,IAAK,cACpJ,CAAC;MACH;IACF,CAAC,CAAC;EACJ;EAEA,IAAID,IAAI,CAACE,QAAQ,EAAE;IACjBF,IAAI,CAACE,QAAQ,CAACL,OAAO,CAACC,wCAAwC,CAAC;EACjE;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timers.js","names":["globalObj","window","global","runWithRealTimers","callback","fakeTimersType","getJestFakeTimersType","jest","useRealTimers","callbackReturnValue","fakeTimersConfig","getFakeTimersConfigFromType","useFakeTimers","setTimeout","process","env","RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS","_isMockFunction","clock","getRealSystemTime","type","legacyFakeTimers","jestFakeTimersAreEnabled","Boolean","exports","setImmediatePolyfill","fn","bindTimeFunctions","clearTimeoutFn","clearTimeout","setImmediateFn","setImmediate","setTimeoutFn"],"sources":["../../src/helpers/timers.ts"],"sourcesContent":["// Most content of this file sourced directly from https://github.com/testing-library/dom-testing-library/blob/main/src/helpers.js\n/* globals jest */\nconst globalObj = typeof window === 'undefined' ? global : window;\n\ntype FakeTimersTypes = 'modern' | 'legacy';\n\n// Currently this fn only supports jest timers, but it could support other test runners in the future.\nfunction runWithRealTimers<T>(callback: () => T): T {\n const fakeTimersType = getJestFakeTimersType();\n if (fakeTimersType) {\n jest.useRealTimers();\n }\n\n const callbackReturnValue = callback();\n\n if (fakeTimersType) {\n const fakeTimersConfig = getFakeTimersConfigFromType(fakeTimersType);\n jest.useFakeTimers(fakeTimersConfig);\n }\n\n return callbackReturnValue;\n}\n\nfunction getJestFakeTimersType(): FakeTimersTypes | null {\n // istanbul ignore if\n if (\n typeof jest === 'undefined' ||\n typeof globalObj.setTimeout === 'undefined' ||\n process.env.RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS\n ) {\n return null;\n }\n\n if (\n // @ts-expect-error jest mutates setTimeout\n typeof globalObj.setTimeout._isMockFunction !== 'undefined' &&\n // @ts-expect-error jest mutates setTimeout\n globalObj.setTimeout._isMockFunction\n ) {\n return 'legacy';\n }\n\n if (\n // @ts-expect-error jest mutates setTimeout\n typeof globalObj.setTimeout.clock !== 'undefined' &&\n typeof jest.getRealSystemTime !== 'undefined'\n ) {\n try {\n // jest.getRealSystemTime is only supported for Jest's `modern` fake timers and otherwise throws\n jest.getRealSystemTime();\n return 'modern';\n } catch {\n // not using Jest's modern fake timers\n }\n }\n\n return null;\n}\n\nfunction getFakeTimersConfigFromType(type: FakeTimersTypes) {\n return type === 'legacy'\n ? { legacyFakeTimers: true }\n : { legacyFakeTimers: false };\n}\n\nconst jestFakeTimersAreEnabled = (): boolean =>\n Boolean(getJestFakeTimersType());\n\n// we only run our tests in node, and setImmediate is supported in node.\nfunction setImmediatePolyfill(fn: Function) {\n return globalObj.setTimeout(fn, 0);\n}\n\ntype BindTimeFunctions = {\n clearTimeoutFn: typeof clearTimeout;\n setImmediateFn: typeof setImmediate;\n setTimeoutFn: typeof setTimeout;\n};\n\nfunction bindTimeFunctions(): BindTimeFunctions {\n return {\n clearTimeoutFn: globalObj.clearTimeout,\n setImmediateFn: globalObj.setImmediate || setImmediatePolyfill,\n setTimeoutFn: globalObj.setTimeout,\n };\n}\n\nconst { clearTimeoutFn, setImmediateFn, setTimeoutFn } = runWithRealTimers(\n bindTimeFunctions\n) as BindTimeFunctions;\n\nexport {\n runWithRealTimers,\n jestFakeTimersAreEnabled,\n clearTimeoutFn as clearTimeout,\n setImmediateFn as setImmediate,\n setTimeoutFn as setTimeout,\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA,MAAMA,SAAS,GAAG,OAAOC,MAAM,KAAK,WAAW,GAAGC,MAAM,GAAGD,MAAM;AAIjE;AACA,SAASE,iBAAiBA,CAAIC,QAAiB,EAAK;EAClD,MAAMC,cAAc,GAAGC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"timers.js","names":["globalObj","window","global","runWithRealTimers","callback","fakeTimersType","getJestFakeTimersType","jest","useRealTimers","callbackReturnValue","fakeTimersConfig","getFakeTimersConfigFromType","useFakeTimers","setTimeout","process","env","RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS","_isMockFunction","clock","getRealSystemTime","type","legacyFakeTimers","jestFakeTimersAreEnabled","Boolean","exports","setImmediatePolyfill","fn","bindTimeFunctions","clearTimeoutFn","clearTimeout","setImmediateFn","setImmediate","setTimeoutFn"],"sources":["../../src/helpers/timers.ts"],"sourcesContent":["// Most content of this file sourced directly from https://github.com/testing-library/dom-testing-library/blob/main/src/helpers.js\n/* globals jest */\nconst globalObj = typeof window === 'undefined' ? global : window;\n\ntype FakeTimersTypes = 'modern' | 'legacy';\n\n// Currently this fn only supports jest timers, but it could support other test runners in the future.\nfunction runWithRealTimers<T>(callback: () => T): T {\n const fakeTimersType = getJestFakeTimersType();\n if (fakeTimersType) {\n jest.useRealTimers();\n }\n\n const callbackReturnValue = callback();\n\n if (fakeTimersType) {\n const fakeTimersConfig = getFakeTimersConfigFromType(fakeTimersType);\n jest.useFakeTimers(fakeTimersConfig);\n }\n\n return callbackReturnValue;\n}\n\nfunction getJestFakeTimersType(): FakeTimersTypes | null {\n // istanbul ignore if\n if (\n typeof jest === 'undefined' ||\n typeof globalObj.setTimeout === 'undefined' ||\n process.env.RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS\n ) {\n return null;\n }\n\n if (\n // @ts-expect-error jest mutates setTimeout\n typeof globalObj.setTimeout._isMockFunction !== 'undefined' &&\n // @ts-expect-error jest mutates setTimeout\n globalObj.setTimeout._isMockFunction\n ) {\n return 'legacy';\n }\n\n if (\n // @ts-expect-error jest mutates setTimeout\n typeof globalObj.setTimeout.clock !== 'undefined' &&\n typeof jest.getRealSystemTime !== 'undefined'\n ) {\n try {\n // jest.getRealSystemTime is only supported for Jest's `modern` fake timers and otherwise throws\n jest.getRealSystemTime();\n return 'modern';\n } catch {\n // not using Jest's modern fake timers\n }\n }\n\n return null;\n}\n\nfunction getFakeTimersConfigFromType(type: FakeTimersTypes) {\n return type === 'legacy'\n ? { legacyFakeTimers: true }\n : { legacyFakeTimers: false };\n}\n\nconst jestFakeTimersAreEnabled = (): boolean =>\n Boolean(getJestFakeTimersType());\n\n// we only run our tests in node, and setImmediate is supported in node.\nfunction setImmediatePolyfill(fn: Function) {\n return globalObj.setTimeout(fn, 0);\n}\n\ntype BindTimeFunctions = {\n clearTimeoutFn: typeof clearTimeout;\n setImmediateFn: typeof setImmediate;\n setTimeoutFn: typeof setTimeout;\n};\n\nfunction bindTimeFunctions(): BindTimeFunctions {\n return {\n clearTimeoutFn: globalObj.clearTimeout,\n setImmediateFn: globalObj.setImmediate || setImmediatePolyfill,\n setTimeoutFn: globalObj.setTimeout,\n };\n}\n\nconst { clearTimeoutFn, setImmediateFn, setTimeoutFn } = runWithRealTimers(\n bindTimeFunctions\n) as BindTimeFunctions;\n\nexport {\n runWithRealTimers,\n jestFakeTimersAreEnabled,\n clearTimeoutFn as clearTimeout,\n setImmediateFn as setImmediate,\n setTimeoutFn as setTimeout,\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA,MAAMA,SAAS,GAAG,OAAOC,MAAM,KAAK,WAAW,GAAGC,MAAM,GAAGD,MAAM;AAIjE;AACA,SAASE,iBAAiBA,CAAIC,QAAiB,EAAK;EAClD,MAAMC,cAAc,GAAGC,qBAAqB,CAAC,CAAC;EAC9C,IAAID,cAAc,EAAE;IAClBE,IAAI,CAACC,aAAa,CAAC,CAAC;EACtB;EAEA,MAAMC,mBAAmB,GAAGL,QAAQ,CAAC,CAAC;EAEtC,IAAIC,cAAc,EAAE;IAClB,MAAMK,gBAAgB,GAAGC,2BAA2B,CAACN,cAAc,CAAC;IACpEE,IAAI,CAACK,aAAa,CAACF,gBAAgB,CAAC;EACtC;EAEA,OAAOD,mBAAmB;AAC5B;AAEA,SAASH,qBAAqBA,CAAA,EAA2B;EACvD;EACA,IACE,OAAOC,IAAI,KAAK,WAAW,IAC3B,OAAOP,SAAS,CAACa,UAAU,KAAK,WAAW,IAC3CC,OAAO,CAACC,GAAG,CAACC,iCAAiC,EAC7C;IACA,OAAO,IAAI;EACb;EAEA;EACE;EACA,OAAOhB,SAAS,CAACa,UAAU,CAACI,eAAe,KAAK,WAAW;EAC3D;EACAjB,SAAS,CAACa,UAAU,CAACI,eAAe,EACpC;IACA,OAAO,QAAQ;EACjB;EAEA;EACE;EACA,OAAOjB,SAAS,CAACa,UAAU,CAACK,KAAK,KAAK,WAAW,IACjD,OAAOX,IAAI,CAACY,iBAAiB,KAAK,WAAW,EAC7C;IACA,IAAI;MACF;MACAZ,IAAI,CAACY,iBAAiB,CAAC,CAAC;MACxB,OAAO,QAAQ;IACjB,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;EAEA,OAAO,IAAI;AACb;AAEA,SAASR,2BAA2BA,CAACS,IAAqB,EAAE;EAC1D,OAAOA,IAAI,KAAK,QAAQ,GACpB;IAAEC,gBAAgB,EAAE;EAAK,CAAC,GAC1B;IAAEA,gBAAgB,EAAE;EAAM,CAAC;AACjC;AAEA,MAAMC,wBAAwB,GAAGA,CAAA,KAC/BC,OAAO,CAACjB,qBAAqB,CAAC,CAAC,CAAC;;AAElC;AAAAkB,OAAA,CAAAF,wBAAA,GAAAA,wBAAA;AACA,SAASG,oBAAoBA,CAACC,EAAY,EAAE;EAC1C,OAAO1B,SAAS,CAACa,UAAU,CAACa,EAAE,EAAE,CAAC,CAAC;AACpC;AAQA,SAASC,iBAAiBA,CAAA,EAAsB;EAC9C,OAAO;IACLC,cAAc,EAAE5B,SAAS,CAAC6B,YAAY;IACtCC,cAAc,EAAE9B,SAAS,CAAC+B,YAAY,IAAIN,oBAAoB;IAC9DO,YAAY,EAAEhC,SAAS,CAACa;EAC1B,CAAC;AACH;AAEA,MAAM;EAAEe,cAAc;EAAEE,cAAc;EAAEE;AAAa,CAAC,GAAG7B,iBAAiB,CACxEwB,iBACF,CAAsB;AAACH,OAAA,CAAAX,UAAA,GAAAmB,YAAA;AAAAR,OAAA,CAAAO,YAAA,GAAAD,cAAA;AAAAN,OAAA,CAAAK,YAAA,GAAAD,cAAA"}
|
package/build/index.js
CHANGED
|
@@ -14,7 +14,7 @@ Object.keys(_pure).forEach(function (key) {
|
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
|
-
var _flushMicroTasks = require("./
|
|
17
|
+
var _flushMicroTasks = require("./flush-micro-tasks");
|
|
18
18
|
var _act = require("./act");
|
|
19
19
|
if (typeof process === 'undefined' || !process.env?.RNTL_SKIP_AUTO_CLEANUP) {
|
|
20
20
|
// If we're running in a test runner that supports afterEach
|
|
@@ -25,7 +25,7 @@ if (typeof process === 'undefined' || !process.env?.RNTL_SKIP_AUTO_CLEANUP) {
|
|
|
25
25
|
if (typeof afterEach === 'function') {
|
|
26
26
|
// eslint-disable-next-line no-undef
|
|
27
27
|
afterEach(async () => {
|
|
28
|
-
await (0, _flushMicroTasks.
|
|
28
|
+
await (0, _flushMicroTasks.flushMicroTasksLegacy)();
|
|
29
29
|
(0, _pure.cleanup)();
|
|
30
30
|
});
|
|
31
31
|
}
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_pure","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_flushMicroTasks","_act","process","env","RNTL_SKIP_AUTO_CLEANUP","afterEach","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_pure","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_flushMicroTasks","_act","process","env","RNTL_SKIP_AUTO_CLEANUP","afterEach","flushMicroTasksLegacy","cleanup","beforeAll","afterAll","previousIsReactActEnvironment","getIsReactActEnvironment","setReactActEnvironment"],"sources":["../src/index.ts"],"sourcesContent":["import { cleanup } from './pure';\nimport { flushMicroTasksLegacy } from './flush-micro-tasks';\nimport { getIsReactActEnvironment, setReactActEnvironment } from './act';\n\nif (typeof process === 'undefined' || !process.env?.RNTL_SKIP_AUTO_CLEANUP) {\n // If we're running in a test runner that supports afterEach\n // then we'll automatically run cleanup afterEach test\n // this ensures that tests run in isolation from each other\n // if you don't like this then either import the `pure` module\n // or set the RNTL_SKIP_AUTO_CLEANUP env variable to 'true'.\n if (typeof afterEach === 'function') {\n // eslint-disable-next-line no-undef\n afterEach(async () => {\n await flushMicroTasksLegacy();\n cleanup();\n });\n }\n\n if (typeof beforeAll === 'function' && typeof afterAll === 'function') {\n // This matches the behavior of React < 18.\n let previousIsReactActEnvironment = getIsReactActEnvironment();\n beforeAll(() => {\n previousIsReactActEnvironment = getIsReactActEnvironment();\n setReactActEnvironment(true);\n });\n\n afterAll(() => {\n setReactActEnvironment(previousIsReactActEnvironment);\n });\n }\n}\n\nexport * from './pure';\n"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAgCAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AA/BA,IAAAK,gBAAA,GAAAT,OAAA;AACA,IAAAU,IAAA,GAAAV,OAAA;AAEA,IAAI,OAAOW,OAAO,KAAK,WAAW,IAAI,CAACA,OAAO,CAACC,GAAG,EAAEC,sBAAsB,EAAE;EAC1E;EACA;EACA;EACA;EACA;EACA,IAAI,OAAOC,SAAS,KAAK,UAAU,EAAE;IACnC;IACAA,SAAS,CAAC,YAAY;MACpB,MAAM,IAAAC,sCAAqB,EAAC,CAAC;MAC7B,IAAAC,aAAO,EAAC,CAAC;IACX,CAAC,CAAC;EACJ;EAEA,IAAI,OAAOC,SAAS,KAAK,UAAU,IAAI,OAAOC,QAAQ,KAAK,UAAU,EAAE;IACrE;IACA,IAAIC,6BAA6B,GAAG,IAAAC,6BAAwB,EAAC,CAAC;IAC9DH,SAAS,CAAC,MAAM;MACdE,6BAA6B,GAAG,IAAAC,6BAAwB,EAAC,CAAC;MAC1D,IAAAC,2BAAsB,EAAC,IAAI,CAAC;IAC9B,CAAC,CAAC;IAEFH,QAAQ,CAAC,MAAM;MACb,IAAAG,2BAAsB,EAACF,6BAA6B,CAAC;IACvD,CAAC,CAAC;EACJ;AACF"}
|
package/build/matches.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matches.js","names":["matches","matcher","text","normalizer","getDefaultNormalizer","exact","normalizedText","normalizedMatcher","toLowerCase","includes","lastIndex","test","trim","collapseWhitespace","replace"],"sources":["../src/matches.ts"],"sourcesContent":["export type NormalizerFn = (textToNormalize: string) => string;\n\nexport type TextMatch = string | RegExp;\nexport type TextMatchOptions = {\n exact?: boolean;\n normalizer?: NormalizerFn;\n};\n\nexport function matches(\n matcher: TextMatch,\n text: string,\n normalizer: NormalizerFn = getDefaultNormalizer(),\n exact: boolean = true\n): boolean {\n if (typeof text !== 'string') {\n return false;\n }\n\n const normalizedText = normalizer(text);\n if (typeof matcher === 'string') {\n const normalizedMatcher = normalizer(matcher);\n return exact\n ? normalizedText === normalizedMatcher\n : normalizedText.toLowerCase().includes(normalizedMatcher.toLowerCase());\n } else {\n // Reset state for global regexes: https://stackoverflow.com/a/1520839/484499\n matcher.lastIndex = 0;\n return matcher.test(normalizedText);\n }\n}\n\ntype NormalizerConfig = {\n trim?: boolean;\n collapseWhitespace?: boolean;\n};\n\nexport function getDefaultNormalizer({\n trim = true,\n collapseWhitespace = true,\n}: NormalizerConfig = {}): NormalizerFn {\n return (text: string) => {\n let normalizedText = text;\n normalizedText = trim ? normalizedText.trim() : normalizedText;\n normalizedText = collapseWhitespace\n ? normalizedText.replace(/\\s+/g, ' ')\n : normalizedText;\n return normalizedText;\n };\n}\n"],"mappings":";;;;;;;AAQO,SAASA,OAAOA,CACrBC,OAAkB,EAClBC,IAAY,EACZC,UAAwB,GAAGC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"matches.js","names":["matches","matcher","text","normalizer","getDefaultNormalizer","exact","normalizedText","normalizedMatcher","toLowerCase","includes","lastIndex","test","trim","collapseWhitespace","replace"],"sources":["../src/matches.ts"],"sourcesContent":["export type NormalizerFn = (textToNormalize: string) => string;\n\nexport type TextMatch = string | RegExp;\nexport type TextMatchOptions = {\n exact?: boolean;\n normalizer?: NormalizerFn;\n};\n\nexport function matches(\n matcher: TextMatch,\n text: string,\n normalizer: NormalizerFn = getDefaultNormalizer(),\n exact: boolean = true\n): boolean {\n if (typeof text !== 'string') {\n return false;\n }\n\n const normalizedText = normalizer(text);\n if (typeof matcher === 'string') {\n const normalizedMatcher = normalizer(matcher);\n return exact\n ? normalizedText === normalizedMatcher\n : normalizedText.toLowerCase().includes(normalizedMatcher.toLowerCase());\n } else {\n // Reset state for global regexes: https://stackoverflow.com/a/1520839/484499\n matcher.lastIndex = 0;\n return matcher.test(normalizedText);\n }\n}\n\ntype NormalizerConfig = {\n trim?: boolean;\n collapseWhitespace?: boolean;\n};\n\nexport function getDefaultNormalizer({\n trim = true,\n collapseWhitespace = true,\n}: NormalizerConfig = {}): NormalizerFn {\n return (text: string) => {\n let normalizedText = text;\n normalizedText = trim ? normalizedText.trim() : normalizedText;\n normalizedText = collapseWhitespace\n ? normalizedText.replace(/\\s+/g, ' ')\n : normalizedText;\n return normalizedText;\n };\n}\n"],"mappings":";;;;;;;AAQO,SAASA,OAAOA,CACrBC,OAAkB,EAClBC,IAAY,EACZC,UAAwB,GAAGC,oBAAoB,CAAC,CAAC,EACjDC,KAAc,GAAG,IAAI,EACZ;EACT,IAAI,OAAOH,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAO,KAAK;EACd;EAEA,MAAMI,cAAc,GAAGH,UAAU,CAACD,IAAI,CAAC;EACvC,IAAI,OAAOD,OAAO,KAAK,QAAQ,EAAE;IAC/B,MAAMM,iBAAiB,GAAGJ,UAAU,CAACF,OAAO,CAAC;IAC7C,OAAOI,KAAK,GACRC,cAAc,KAAKC,iBAAiB,GACpCD,cAAc,CAACE,WAAW,CAAC,CAAC,CAACC,QAAQ,CAACF,iBAAiB,CAACC,WAAW,CAAC,CAAC,CAAC;EAC5E,CAAC,MAAM;IACL;IACAP,OAAO,CAACS,SAAS,GAAG,CAAC;IACrB,OAAOT,OAAO,CAACU,IAAI,CAACL,cAAc,CAAC;EACrC;AACF;AAOO,SAASF,oBAAoBA,CAAC;EACnCQ,IAAI,GAAG,IAAI;EACXC,kBAAkB,GAAG;AACL,CAAC,GAAG,CAAC,CAAC,EAAgB;EACtC,OAAQX,IAAY,IAAK;IACvB,IAAII,cAAc,GAAGJ,IAAI;IACzBI,cAAc,GAAGM,IAAI,GAAGN,cAAc,CAACM,IAAI,CAAC,CAAC,GAAGN,cAAc;IAC9DA,cAAc,GAAGO,kBAAkB,GAC/BP,cAAc,CAACQ,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,GACnCR,cAAc;IAClB,OAAOA,cAAc;EACvB,CAAC;AACH"}
|
package/build/pure.d.ts
CHANGED
|
@@ -10,6 +10,6 @@ export { isHiddenFromAccessibility, isInaccessible, } from './helpers/accessibli
|
|
|
10
10
|
export { getDefaultNormalizer } from './matches';
|
|
11
11
|
export { renderHook } from './renderHook';
|
|
12
12
|
export { screen } from './screen';
|
|
13
|
-
export type { RenderOptions, RenderResult, RenderResult as RenderAPI, } from './render';
|
|
13
|
+
export type { RenderOptions, RenderResult, RenderResult as RenderAPI, DebugFunction, } from './render';
|
|
14
14
|
export type { RenderHookOptions, RenderHookResult } from './renderHook';
|
|
15
15
|
export type { Config } from './config';
|
package/build/pure.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pure.js","names":["_act","_interopRequireDefault","require","_cleanup","_fireEvent","_render","_waitFor","_waitForElementToBeRemoved","_within","_config","_accessiblity","_matches","_renderHook","_screen","obj","__esModule","default"],"sources":["../src/pure.ts"],"sourcesContent":["export { default as act } from './act';\nexport { default as cleanup } from './cleanup';\nexport { default as fireEvent } from './fireEvent';\nexport { default as render } from './render';\nexport { default as waitFor } from './waitFor';\nexport { default as waitForElementToBeRemoved } from './waitForElementToBeRemoved';\nexport { within, getQueriesForElement } from './within';\n\nexport { configure, resetToDefaults } from './config';\nexport {\n isHiddenFromAccessibility,\n isInaccessible,\n} from './helpers/accessiblity';\nexport { getDefaultNormalizer } from './matches';\nexport { renderHook } from './renderHook';\nexport { screen } from './screen';\n\nexport type {\n RenderOptions,\n RenderResult,\n RenderResult as RenderAPI,\n} from './render';\nexport type { RenderHookOptions, RenderHookResult } from './renderHook';\nexport type { Config } from './config';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,QAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,0BAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAEA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AAIA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,WAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AAAkC,SAAAD,uBAAAa,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA"}
|
|
1
|
+
{"version":3,"file":"pure.js","names":["_act","_interopRequireDefault","require","_cleanup","_fireEvent","_render","_waitFor","_waitForElementToBeRemoved","_within","_config","_accessiblity","_matches","_renderHook","_screen","obj","__esModule","default"],"sources":["../src/pure.ts"],"sourcesContent":["export { default as act } from './act';\nexport { default as cleanup } from './cleanup';\nexport { default as fireEvent } from './fireEvent';\nexport { default as render } from './render';\nexport { default as waitFor } from './waitFor';\nexport { default as waitForElementToBeRemoved } from './waitForElementToBeRemoved';\nexport { within, getQueriesForElement } from './within';\n\nexport { configure, resetToDefaults } from './config';\nexport {\n isHiddenFromAccessibility,\n isInaccessible,\n} from './helpers/accessiblity';\nexport { getDefaultNormalizer } from './matches';\nexport { renderHook } from './renderHook';\nexport { screen } from './screen';\n\nexport type {\n RenderOptions,\n RenderResult,\n RenderResult as RenderAPI,\n DebugFunction,\n} from './render';\nexport type { RenderHookOptions, RenderHookResult } from './renderHook';\nexport type { Config } from './config';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,QAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,0BAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAEA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AAIA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,WAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AAAkC,SAAAD,uBAAAa,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA"}
|