@testing-library/react-native 11.3.0 → 11.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/build/act.js +9 -15
- package/build/act.js.map +1 -1
- package/build/cleanup.d.ts +1 -1
- package/build/cleanup.js +0 -4
- package/build/cleanup.js.map +1 -1
- package/build/config.d.ts +15 -2
- package/build/config.js +16 -8
- package/build/config.js.map +1 -1
- package/build/fireEvent.js +3 -31
- package/build/fireEvent.js.map +1 -1
- package/build/flushMicroTasks.d.ts +1 -1
- package/build/flushMicroTasks.js +0 -3
- package/build/flushMicroTasks.js.map +1 -1
- package/build/helpers/accessiblity.d.ts +10 -1
- package/build/helpers/accessiblity.js +28 -24
- package/build/helpers/accessiblity.js.map +1 -1
- package/build/helpers/component-tree.js +6 -27
- package/build/helpers/component-tree.js.map +1 -1
- package/build/helpers/debugDeep.d.ts +5 -1
- package/build/helpers/debugDeep.js +7 -6
- package/build/helpers/debugDeep.js.map +1 -1
- package/build/helpers/debugShallow.js +0 -5
- package/build/helpers/debugShallow.js.map +1 -1
- package/build/helpers/errors.js +4 -25
- package/build/helpers/errors.js.map +1 -1
- package/build/helpers/filterNodeByType.js +0 -2
- package/build/helpers/filterNodeByType.js.map +1 -1
- package/build/helpers/findAll.d.ts +10 -0
- package/build/helpers/findAll.js +44 -0
- package/build/helpers/findAll.js.map +1 -0
- package/build/helpers/format.d.ts +5 -1
- package/build/helpers/format.js +17 -7
- package/build/helpers/format.js.map +1 -1
- package/build/helpers/getTextContent.d.ts +2 -0
- package/build/helpers/getTextContent.js +20 -0
- package/build/helpers/getTextContent.js.map +1 -0
- package/build/helpers/matchers/accessibilityState.d.ts +3 -0
- package/build/helpers/matchers/accessibilityState.js +28 -0
- package/build/helpers/matchers/accessibilityState.js.map +1 -0
- package/build/helpers/matchers/accessibilityValue.d.ts +9 -0
- package/build/helpers/matchers/accessibilityValue.js +12 -0
- package/build/helpers/matchers/accessibilityValue.js.map +1 -0
- package/build/helpers/matchers/matchArrayProp.js +0 -3
- package/build/helpers/matchers/matchArrayProp.js.map +1 -1
- package/build/helpers/matchers/matchObjectProp.js +0 -2
- package/build/helpers/matchers/matchObjectProp.js.map +1 -1
- package/build/helpers/matchers/matchStringProp.js +0 -3
- package/build/helpers/matchers/matchStringProp.js.map +1 -1
- package/build/helpers/matchers/matchTextContent.d.ts +3 -0
- package/build/helpers/matchers/matchTextContent.js +22 -0
- package/build/helpers/matchers/matchTextContent.js.map +1 -0
- package/build/helpers/stringValidation.js +0 -7
- package/build/helpers/stringValidation.js.map +1 -1
- package/build/helpers/timers.js +10 -21
- package/build/helpers/timers.js.map +1 -1
- package/build/index.flow.js +169 -56
- package/build/index.js +0 -6
- package/build/index.js.map +1 -1
- package/build/matches.d.ts +7 -3
- package/build/matches.js +2 -4
- package/build/matches.js.map +1 -1
- package/build/pure.d.ts +12 -23
- package/build/pure.js +8 -15
- package/build/pure.js.map +1 -1
- package/build/queries/a11yState.d.ts +15 -14
- package/build/queries/a11yState.js +16 -13
- package/build/queries/a11yState.js.map +1 -1
- package/build/queries/a11yValue.d.ts +15 -20
- package/build/queries/a11yValue.js +16 -13
- package/build/queries/a11yValue.js.map +1 -1
- package/build/queries/displayValue.d.ts +11 -9
- package/build/queries/displayValue.js +2 -12
- package/build/queries/displayValue.js.map +1 -1
- package/build/queries/hintText.d.ts +23 -20
- package/build/queries/hintText.js +11 -11
- package/build/queries/hintText.js.map +1 -1
- package/build/queries/labelText.d.ts +11 -8
- package/build/queries/labelText.js +11 -11
- package/build/queries/labelText.js.map +1 -1
- package/build/queries/makeQueries.d.ts +9 -9
- package/build/queries/makeQueries.js +40 -24
- package/build/queries/makeQueries.js.map +1 -1
- package/build/queries/options.d.ts +11 -0
- package/build/queries/options.js +2 -0
- package/build/queries/options.js.map +1 -0
- package/build/queries/placeholderText.d.ts +11 -9
- package/build/queries/placeholderText.js +2 -12
- package/build/queries/placeholderText.js.map +1 -1
- package/build/queries/role.d.ts +7 -3
- package/build/queries/role.js +32 -13
- package/build/queries/role.js.map +1 -1
- package/build/queries/testId.d.ts +11 -9
- package/build/queries/testId.js +3 -11
- package/build/queries/testId.js.map +1 -1
- package/build/queries/text.d.ts +11 -13
- package/build/queries/text.js +6 -71
- package/build/queries/text.js.map +1 -1
- package/build/queries/unsafeProps.d.ts +1 -1
- package/build/queries/unsafeProps.js +2 -11
- package/build/queries/unsafeProps.js.map +1 -1
- package/build/queries/unsafeType.d.ts +1 -1
- package/build/queries/unsafeType.js +2 -9
- package/build/queries/unsafeType.js.map +1 -1
- package/build/react-versions.js +0 -4
- package/build/react-versions.js.map +1 -1
- package/build/render.d.ts +88 -141
- package/build/render.js +21 -31
- package/build/render.js.map +1 -1
- package/build/renderHook.d.ts +2 -2
- package/build/renderHook.js +2 -12
- package/build/renderHook.js.map +1 -1
- package/build/screen.js +0 -6
- package/build/screen.js.map +1 -1
- package/build/shallow.js +0 -6
- package/build/shallow.js.map +1 -1
- package/build/waitFor.d.ts +1 -1
- package/build/waitFor.js +29 -52
- package/build/waitFor.js.map +1 -1
- package/build/waitForElementToBeRemoved.js +2 -11
- package/build/waitForElementToBeRemoved.js.map +1 -1
- package/build/within.d.ts +84 -138
- package/build/within.js +2 -14
- package/build/within.js.map +1 -1
- package/package.json +12 -11
- package/typings/index.flow.js +169 -56
package/build/render.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import TestRenderer from 'react-test-renderer';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
|
|
3
|
+
import { DebugOptions } from './helpers/debugDeep';
|
|
4
|
+
export type RenderOptions = {
|
|
4
5
|
wrapper?: React.ComponentType<any>;
|
|
5
6
|
createNodeMock?: (element: React.ReactElement) => any;
|
|
6
7
|
unstable_validateStringsRenderedWithinText?: boolean;
|
|
7
8
|
};
|
|
8
|
-
export
|
|
9
|
+
export type RenderResult = ReturnType<typeof render>;
|
|
9
10
|
/**
|
|
10
11
|
* Renders test component deeply using react-test-renderer and exposes helpers
|
|
11
12
|
* to assert on the output.
|
|
@@ -33,159 +34,105 @@ export default function render<T>(component: React.ReactElement<T>, { wrapper: W
|
|
|
33
34
|
UNSAFE_getAllByType: <P_1>(type: React.ComponentType<P_1>) => TestRenderer.ReactTestInstance[];
|
|
34
35
|
UNSAFE_queryByType: <P_2>(type: React.ComponentType<P_2>) => TestRenderer.ReactTestInstance | null;
|
|
35
36
|
UNSAFE_queryAllByType: <P_3>(type: React.ComponentType<P_3>) => TestRenderer.ReactTestInstance[];
|
|
36
|
-
getByA11yValue: import("./queries/makeQueries").GetByQuery<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
min?: number | undefined;
|
|
62
|
-
max?: number | undefined;
|
|
63
|
-
now?: number | undefined;
|
|
64
|
-
text?: string | undefined;
|
|
65
|
-
}, void>;
|
|
66
|
-
findAllByA11yValue: import("./queries/makeQueries").FindAllByQuery<{
|
|
67
|
-
min?: number | undefined;
|
|
68
|
-
max?: number | undefined;
|
|
69
|
-
now?: number | undefined;
|
|
70
|
-
text?: string | undefined;
|
|
71
|
-
}, void>;
|
|
72
|
-
getByAccessibilityValue: import("./queries/makeQueries").GetByQuery<{
|
|
73
|
-
min?: number | undefined;
|
|
74
|
-
max?: number | undefined;
|
|
75
|
-
now?: number | undefined;
|
|
76
|
-
text?: string | undefined;
|
|
77
|
-
}, void>;
|
|
78
|
-
getAllByAccessibilityValue: import("./queries/makeQueries").GetAllByQuery<{
|
|
79
|
-
min?: number | undefined;
|
|
80
|
-
max?: number | undefined;
|
|
81
|
-
now?: number | undefined;
|
|
82
|
-
text?: string | undefined;
|
|
83
|
-
}, void>;
|
|
84
|
-
queryByAccessibilityValue: import("./queries/makeQueries").QueryByQuery<{
|
|
85
|
-
min?: number | undefined;
|
|
86
|
-
max?: number | undefined;
|
|
87
|
-
now?: number | undefined;
|
|
88
|
-
text?: string | undefined;
|
|
89
|
-
}, void>;
|
|
90
|
-
queryAllByAccessibilityValue: import("./queries/makeQueries").QueryAllByQuery<{
|
|
91
|
-
min?: number | undefined;
|
|
92
|
-
max?: number | undefined;
|
|
93
|
-
now?: number | undefined;
|
|
94
|
-
text?: string | undefined;
|
|
95
|
-
}, void>;
|
|
96
|
-
findByAccessibilityValue: import("./queries/makeQueries").FindByQuery<{
|
|
97
|
-
min?: number | undefined;
|
|
98
|
-
max?: number | undefined;
|
|
99
|
-
now?: number | undefined;
|
|
100
|
-
text?: string | undefined;
|
|
101
|
-
}, void>;
|
|
102
|
-
findAllByAccessibilityValue: import("./queries/makeQueries").FindAllByQuery<{
|
|
103
|
-
min?: number | undefined;
|
|
104
|
-
max?: number | undefined;
|
|
105
|
-
now?: number | undefined;
|
|
106
|
-
text?: string | undefined;
|
|
107
|
-
}, void>;
|
|
108
|
-
getByA11yState: import("./queries/makeQueries").GetByQuery<import("react-native").AccessibilityState, void>;
|
|
109
|
-
getAllByA11yState: import("./queries/makeQueries").GetAllByQuery<import("react-native").AccessibilityState, void>;
|
|
110
|
-
queryByA11yState: import("./queries/makeQueries").QueryByQuery<import("react-native").AccessibilityState, void>;
|
|
111
|
-
queryAllByA11yState: import("./queries/makeQueries").QueryAllByQuery<import("react-native").AccessibilityState, void>;
|
|
112
|
-
findByA11yState: import("./queries/makeQueries").FindByQuery<import("react-native").AccessibilityState, void>;
|
|
113
|
-
findAllByA11yState: import("./queries/makeQueries").FindAllByQuery<import("react-native").AccessibilityState, void>;
|
|
114
|
-
getByAccessibilityState: import("./queries/makeQueries").GetByQuery<import("react-native").AccessibilityState, void>;
|
|
115
|
-
getAllByAccessibilityState: import("./queries/makeQueries").GetAllByQuery<import("react-native").AccessibilityState, void>;
|
|
116
|
-
queryByAccessibilityState: import("./queries/makeQueries").QueryByQuery<import("react-native").AccessibilityState, void>;
|
|
117
|
-
queryAllByAccessibilityState: import("./queries/makeQueries").QueryAllByQuery<import("react-native").AccessibilityState, void>;
|
|
118
|
-
findByAccessibilityState: import("./queries/makeQueries").FindByQuery<import("react-native").AccessibilityState, void>;
|
|
119
|
-
findAllByAccessibilityState: import("./queries/makeQueries").FindAllByQuery<import("react-native").AccessibilityState, void>;
|
|
120
|
-
getByRole: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, {
|
|
37
|
+
getByA11yValue: import("./queries/makeQueries").GetByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
38
|
+
getAllByA11yValue: import("./queries/makeQueries").GetAllByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
39
|
+
queryByA11yValue: import("./queries/makeQueries").QueryByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
40
|
+
queryAllByA11yValue: import("./queries/makeQueries").QueryAllByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
41
|
+
findByA11yValue: import("./queries/makeQueries").FindByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
42
|
+
findAllByA11yValue: import("./queries/makeQueries").FindAllByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
43
|
+
getByAccessibilityValue: import("./queries/makeQueries").GetByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
44
|
+
getAllByAccessibilityValue: import("./queries/makeQueries").GetAllByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
45
|
+
queryByAccessibilityValue: import("./queries/makeQueries").QueryByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
46
|
+
queryAllByAccessibilityValue: import("./queries/makeQueries").QueryAllByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
47
|
+
findByAccessibilityValue: import("./queries/makeQueries").FindByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
48
|
+
findAllByAccessibilityValue: import("./queries/makeQueries").FindAllByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
49
|
+
getByA11yState: import("./queries/makeQueries").GetByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
50
|
+
getAllByA11yState: import("./queries/makeQueries").GetAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
51
|
+
queryByA11yState: import("./queries/makeQueries").QueryByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
52
|
+
queryAllByA11yState: import("./queries/makeQueries").QueryAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
53
|
+
findByA11yState: import("./queries/makeQueries").FindByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
54
|
+
findAllByA11yState: import("./queries/makeQueries").FindAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
55
|
+
getByAccessibilityState: import("./queries/makeQueries").GetByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
56
|
+
getAllByAccessibilityState: import("./queries/makeQueries").GetAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
57
|
+
queryByAccessibilityState: import("./queries/makeQueries").QueryByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
58
|
+
queryAllByAccessibilityState: import("./queries/makeQueries").QueryAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
59
|
+
findByAccessibilityState: import("./queries/makeQueries").FindByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
60
|
+
findAllByAccessibilityState: import("./queries/makeQueries").FindAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
61
|
+
getByRole: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
121
62
|
name?: import("./matches").TextMatch | undefined;
|
|
63
|
+
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
122
64
|
}>;
|
|
123
|
-
getAllByRole: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, {
|
|
65
|
+
getAllByRole: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
124
66
|
name?: import("./matches").TextMatch | undefined;
|
|
67
|
+
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
125
68
|
}>;
|
|
126
|
-
queryByRole: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, {
|
|
69
|
+
queryByRole: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
127
70
|
name?: import("./matches").TextMatch | undefined;
|
|
71
|
+
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
128
72
|
}>;
|
|
129
|
-
queryAllByRole: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, {
|
|
73
|
+
queryAllByRole: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
130
74
|
name?: import("./matches").TextMatch | undefined;
|
|
75
|
+
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
131
76
|
}>;
|
|
132
|
-
findByRole: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, {
|
|
77
|
+
findByRole: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
133
78
|
name?: import("./matches").TextMatch | undefined;
|
|
79
|
+
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
134
80
|
}>;
|
|
135
|
-
findAllByRole: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, {
|
|
81
|
+
findAllByRole: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
136
82
|
name?: import("./matches").TextMatch | undefined;
|
|
83
|
+
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
137
84
|
}>;
|
|
138
|
-
getByHintText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch,
|
|
139
|
-
getAllByHintText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch,
|
|
140
|
-
queryByHintText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch,
|
|
141
|
-
queryAllByHintText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch,
|
|
142
|
-
findByHintText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch,
|
|
143
|
-
findAllByHintText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch,
|
|
144
|
-
getByA11yHint: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch,
|
|
145
|
-
getAllByA11yHint: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch,
|
|
146
|
-
queryByA11yHint: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch,
|
|
147
|
-
queryAllByA11yHint: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch,
|
|
148
|
-
findByA11yHint: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch,
|
|
149
|
-
findAllByA11yHint: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch,
|
|
150
|
-
getByAccessibilityHint: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch,
|
|
151
|
-
getAllByAccessibilityHint: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch,
|
|
152
|
-
queryByAccessibilityHint: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch,
|
|
153
|
-
queryAllByAccessibilityHint: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch,
|
|
154
|
-
findByAccessibilityHint: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch,
|
|
155
|
-
findAllByAccessibilityHint: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch,
|
|
156
|
-
getByLabelText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch,
|
|
157
|
-
getAllByLabelText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch,
|
|
158
|
-
queryByLabelText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch,
|
|
159
|
-
queryAllByLabelText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch,
|
|
160
|
-
findByLabelText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch,
|
|
161
|
-
findAllByLabelText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch,
|
|
162
|
-
getByPlaceholderText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/
|
|
163
|
-
getAllByPlaceholderText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/
|
|
164
|
-
queryByPlaceholderText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/
|
|
165
|
-
queryAllByPlaceholderText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/
|
|
166
|
-
findByPlaceholderText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/
|
|
167
|
-
findAllByPlaceholderText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/
|
|
168
|
-
getByDisplayValue: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/
|
|
169
|
-
getAllByDisplayValue: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/
|
|
170
|
-
queryByDisplayValue: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/
|
|
171
|
-
queryAllByDisplayValue: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/
|
|
172
|
-
findByDisplayValue: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/
|
|
173
|
-
findAllByDisplayValue: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/
|
|
174
|
-
getByTestId: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/
|
|
175
|
-
getAllByTestId: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/
|
|
176
|
-
queryByTestId: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/
|
|
177
|
-
queryAllByTestId: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/
|
|
178
|
-
findByTestId: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/
|
|
179
|
-
findAllByTestId: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/
|
|
180
|
-
getByText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/
|
|
181
|
-
getAllByText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/
|
|
182
|
-
queryByText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/
|
|
183
|
-
queryAllByText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/
|
|
184
|
-
findByText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/
|
|
185
|
-
findAllByText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/
|
|
85
|
+
getByHintText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
86
|
+
getAllByHintText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
87
|
+
queryByHintText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
88
|
+
queryAllByHintText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
89
|
+
findByHintText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
90
|
+
findAllByHintText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
91
|
+
getByA11yHint: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
92
|
+
getAllByA11yHint: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
93
|
+
queryByA11yHint: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
94
|
+
queryAllByA11yHint: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
95
|
+
findByA11yHint: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
96
|
+
findAllByA11yHint: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
97
|
+
getByAccessibilityHint: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
98
|
+
getAllByAccessibilityHint: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
99
|
+
queryByAccessibilityHint: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
100
|
+
queryAllByAccessibilityHint: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
101
|
+
findByAccessibilityHint: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
102
|
+
findAllByAccessibilityHint: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
103
|
+
getByLabelText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
104
|
+
getAllByLabelText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
105
|
+
queryByLabelText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
106
|
+
queryAllByLabelText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
107
|
+
findByLabelText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
108
|
+
findAllByLabelText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
109
|
+
getByPlaceholderText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
110
|
+
getAllByPlaceholderText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
111
|
+
queryByPlaceholderText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
112
|
+
queryAllByPlaceholderText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
113
|
+
findByPlaceholderText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
114
|
+
findAllByPlaceholderText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
115
|
+
getByDisplayValue: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
116
|
+
getAllByDisplayValue: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
117
|
+
queryByDisplayValue: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
118
|
+
queryAllByDisplayValue: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
119
|
+
findByDisplayValue: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
120
|
+
findAllByDisplayValue: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
121
|
+
getByTestId: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
122
|
+
getAllByTestId: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
123
|
+
queryByTestId: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
124
|
+
queryAllByTestId: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
125
|
+
findByTestId: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
126
|
+
findAllByTestId: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
127
|
+
getByText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
128
|
+
getAllByText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
129
|
+
queryByText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
130
|
+
queryAllByText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
131
|
+
findByText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
132
|
+
findAllByText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
|
|
186
133
|
};
|
|
187
134
|
interface DebugFunction {
|
|
188
|
-
(
|
|
135
|
+
(options?: DebugOptions | string): void;
|
|
189
136
|
shallow: (message?: string) => void;
|
|
190
137
|
}
|
|
191
138
|
export {};
|
package/build/render.js
CHANGED
|
@@ -4,31 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = render;
|
|
7
|
-
|
|
8
7
|
var _reactTestRenderer = _interopRequireDefault(require("react-test-renderer"));
|
|
9
|
-
|
|
10
8
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _act = _interopRequireDefault(require("./act"));
|
|
13
|
-
|
|
14
10
|
var _cleanup = require("./cleanup");
|
|
15
|
-
|
|
16
11
|
var _debugShallow = _interopRequireDefault(require("./helpers/debugShallow"));
|
|
17
|
-
|
|
18
12
|
var _debugDeep = _interopRequireDefault(require("./helpers/debugDeep"));
|
|
19
|
-
|
|
20
13
|
var _within = require("./within");
|
|
21
|
-
|
|
22
14
|
var _screen = require("./screen");
|
|
23
|
-
|
|
24
15
|
var _stringValidation = require("./helpers/stringValidation");
|
|
25
|
-
|
|
16
|
+
var _config = require("./config");
|
|
26
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
-
|
|
28
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
-
|
|
30
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
20
|
/**
|
|
33
21
|
* Renders test component deeply using react-test-renderer and exposes helpers
|
|
34
22
|
* to assert on the output.
|
|
@@ -44,15 +32,12 @@ function render(component, {
|
|
|
44
32
|
createNodeMock
|
|
45
33
|
});
|
|
46
34
|
}
|
|
47
|
-
|
|
48
35
|
const wrap = element => Wrapper ? /*#__PURE__*/React.createElement(Wrapper, null, element) : element;
|
|
49
|
-
|
|
50
36
|
const renderer = renderWithAct(wrap(component), createNodeMock ? {
|
|
51
37
|
createNodeMock
|
|
52
38
|
} : undefined);
|
|
53
39
|
return buildRenderResult(renderer, wrap);
|
|
54
40
|
}
|
|
55
|
-
|
|
56
41
|
function renderWithStringValidation(component, {
|
|
57
42
|
wrapper: Wrapper,
|
|
58
43
|
createNodeMock
|
|
@@ -62,31 +47,27 @@ function renderWithStringValidation(component, {
|
|
|
62
47
|
(0, _stringValidation.validateStringsRenderedWithinText)(_screen.screen.toJSON());
|
|
63
48
|
}
|
|
64
49
|
};
|
|
65
|
-
|
|
66
50
|
const wrap = element => /*#__PURE__*/React.createElement(React.Profiler, {
|
|
67
51
|
id: "renderProfiler",
|
|
68
52
|
onRender: handleRender
|
|
69
53
|
}, Wrapper ? /*#__PURE__*/React.createElement(Wrapper, null, element) : element);
|
|
70
|
-
|
|
71
54
|
const renderer = renderWithAct(wrap(component), createNodeMock ? {
|
|
72
55
|
createNodeMock
|
|
73
56
|
} : undefined);
|
|
74
57
|
(0, _stringValidation.validateStringsRenderedWithinText)(renderer.toJSON());
|
|
75
58
|
return buildRenderResult(renderer, wrap);
|
|
76
59
|
}
|
|
77
|
-
|
|
78
60
|
function buildRenderResult(renderer, wrap) {
|
|
79
61
|
const update = updateWithAct(renderer, wrap);
|
|
80
62
|
const instance = renderer.root;
|
|
81
|
-
|
|
82
63
|
const unmount = () => {
|
|
83
64
|
(0, _act.default)(() => {
|
|
84
65
|
renderer.unmount();
|
|
85
66
|
});
|
|
86
67
|
};
|
|
87
|
-
|
|
88
68
|
(0, _cleanup.addToCleanupQueue)(unmount);
|
|
89
|
-
const result = {
|
|
69
|
+
const result = {
|
|
70
|
+
...(0, _within.getQueriesForElement)(instance),
|
|
90
71
|
update,
|
|
91
72
|
unmount,
|
|
92
73
|
container: instance,
|
|
@@ -98,16 +79,15 @@ function buildRenderResult(renderer, wrap) {
|
|
|
98
79
|
(0, _screen.setRenderResult)(result);
|
|
99
80
|
return result;
|
|
100
81
|
}
|
|
101
|
-
|
|
102
82
|
function renderWithAct(component, options) {
|
|
103
83
|
let renderer;
|
|
104
84
|
(0, _act.default)(() => {
|
|
105
85
|
renderer = _reactTestRenderer.default.create(component, options);
|
|
106
|
-
});
|
|
86
|
+
});
|
|
107
87
|
|
|
88
|
+
// @ts-ignore act is sync, so renderer is always initialised here
|
|
108
89
|
return renderer;
|
|
109
90
|
}
|
|
110
|
-
|
|
111
91
|
function updateWithAct(renderer, wrap) {
|
|
112
92
|
return function (component) {
|
|
113
93
|
(0, _act.default)(() => {
|
|
@@ -115,18 +95,28 @@ function updateWithAct(renderer, wrap) {
|
|
|
115
95
|
});
|
|
116
96
|
};
|
|
117
97
|
}
|
|
118
|
-
|
|
119
98
|
function debug(instance, renderer) {
|
|
120
|
-
function debugImpl(
|
|
99
|
+
function debugImpl(options) {
|
|
100
|
+
const {
|
|
101
|
+
defaultDebugOptions
|
|
102
|
+
} = (0, _config.getConfig)();
|
|
103
|
+
const debugOptions = typeof options === 'string' ? {
|
|
104
|
+
...defaultDebugOptions,
|
|
105
|
+
message: options
|
|
106
|
+
} : {
|
|
107
|
+
...defaultDebugOptions,
|
|
108
|
+
...options
|
|
109
|
+
};
|
|
110
|
+
if (typeof options === 'string') {
|
|
111
|
+
// eslint-disable-next-line no-console
|
|
112
|
+
console.warn('Using debug("message") is deprecated and will be removed in future release, please use debug({ message; "message" }) instead.');
|
|
113
|
+
}
|
|
121
114
|
const json = renderer.toJSON();
|
|
122
|
-
|
|
123
115
|
if (json) {
|
|
124
|
-
return (0, _debugDeep.default)(json,
|
|
116
|
+
return (0, _debugDeep.default)(json, debugOptions);
|
|
125
117
|
}
|
|
126
118
|
}
|
|
127
|
-
|
|
128
119
|
debugImpl.shallow = message => (0, _debugShallow.default)(instance, message);
|
|
129
|
-
|
|
130
120
|
return debugImpl;
|
|
131
121
|
}
|
|
132
122
|
//# sourceMappingURL=render.js.map
|
package/build/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","names":["render","component","wrapper","Wrapper","createNodeMock","unstable_validateStringsRenderedWithinText","renderWithStringValidation","wrap","element","renderer","renderWithAct","undefined","buildRenderResult","handleRender","_","phase","validateStringsRenderedWithinText","screen","toJSON","update","updateWithAct","instance","root","unmount","act","addToCleanupQueue","result","getQueriesForElement","container","rerender","debug","setRenderResult","options","TestRenderer","create","debugImpl","message","json","debugDeep","shallow","debugShallow"],"sources":["../src/render.tsx"],"sourcesContent":["import TestRenderer from 'react-test-renderer';\nimport type { ReactTestInstance, ReactTestRenderer } from 'react-test-renderer';\nimport * as React from 'react';\nimport { Profiler } from 'react';\nimport act from './act';\nimport { addToCleanupQueue } from './cleanup';\nimport debugShallow from './helpers/debugShallow';\nimport debugDeep from './helpers/debugDeep';\nimport { getQueriesForElement } from './within';\nimport { setRenderResult, screen } from './screen';\nimport { validateStringsRenderedWithinText } from './helpers/stringValidation';\n\nexport type RenderOptions = {\n wrapper?: React.ComponentType<any>;\n createNodeMock?: (element: React.ReactElement) => any;\n unstable_validateStringsRenderedWithinText?: boolean;\n};\n\ntype TestRendererOptions = {\n createNodeMock: (element: React.ReactElement) => any;\n};\n\nexport type RenderResult = ReturnType<typeof render>;\n\n/**\n * Renders test component deeply using react-test-renderer and exposes helpers\n * to assert on the output.\n */\nexport default function render<T>(\n component: React.ReactElement<T>,\n {\n wrapper: Wrapper,\n createNodeMock,\n unstable_validateStringsRenderedWithinText,\n }: RenderOptions = {}\n) {\n if (unstable_validateStringsRenderedWithinText) {\n return renderWithStringValidation(component, {\n wrapper: Wrapper,\n createNodeMock,\n });\n }\n\n const wrap = (element: React.ReactElement) =>\n Wrapper ? <Wrapper>{element}</Wrapper> : element;\n\n const renderer = renderWithAct(\n wrap(component),\n createNodeMock ? { createNodeMock } : undefined\n );\n\n return buildRenderResult(renderer, wrap);\n}\n\nfunction renderWithStringValidation<T>(\n component: React.ReactElement<T>,\n {\n wrapper: Wrapper,\n createNodeMock,\n }: Omit<RenderOptions, 'unstable_validateStringsRenderedWithinText'> = {}\n) {\n const handleRender: React.ProfilerProps['onRender'] = (_, phase) => {\n if (phase === 'update') {\n validateStringsRenderedWithinText(screen.toJSON());\n }\n };\n\n const wrap = (element: React.ReactElement) => (\n <Profiler id=\"renderProfiler\" onRender={handleRender}>\n {Wrapper ? <Wrapper>{element}</Wrapper> : element}\n </Profiler>\n );\n\n const renderer = renderWithAct(\n wrap(component),\n createNodeMock ? { createNodeMock } : undefined\n );\n validateStringsRenderedWithinText(renderer.toJSON());\n\n return buildRenderResult(renderer, wrap);\n}\n\nfunction buildRenderResult(\n renderer: ReactTestRenderer,\n wrap: (element: React.ReactElement) => JSX.Element\n) {\n const update = updateWithAct(renderer, wrap);\n const instance = renderer.root;\n\n const unmount = () => {\n act(() => {\n renderer.unmount();\n });\n };\n\n addToCleanupQueue(unmount);\n\n const result = {\n ...getQueriesForElement(instance),\n update,\n unmount,\n container: instance,\n rerender: update, // alias for `update`\n toJSON: renderer.toJSON,\n debug: debug(instance, renderer),\n };\n\n setRenderResult(result);\n return result;\n}\n\nfunction renderWithAct(\n component: React.ReactElement,\n options?: TestRendererOptions\n): ReactTestRenderer {\n let renderer: ReactTestRenderer;\n\n act(() => {\n renderer = TestRenderer.create(component, options);\n });\n\n // @ts-ignore act is sync, so renderer is always initialised here\n return renderer;\n}\n\nfunction updateWithAct(\n renderer: ReactTestRenderer,\n wrap: (innerElement: React.ReactElement) => React.ReactElement\n) {\n return function (component: React.ReactElement) {\n act(() => {\n renderer.update(wrap(component));\n });\n };\n}\n\ninterface DebugFunction {\n (
|
|
1
|
+
{"version":3,"file":"render.js","names":["render","component","wrapper","Wrapper","createNodeMock","unstable_validateStringsRenderedWithinText","renderWithStringValidation","wrap","element","renderer","renderWithAct","undefined","buildRenderResult","handleRender","_","phase","validateStringsRenderedWithinText","screen","toJSON","update","updateWithAct","instance","root","unmount","act","addToCleanupQueue","result","getQueriesForElement","container","rerender","debug","setRenderResult","options","TestRenderer","create","debugImpl","defaultDebugOptions","getConfig","debugOptions","message","console","warn","json","debugDeep","shallow","debugShallow"],"sources":["../src/render.tsx"],"sourcesContent":["import TestRenderer from 'react-test-renderer';\nimport type { ReactTestInstance, ReactTestRenderer } from 'react-test-renderer';\nimport * as React from 'react';\nimport { Profiler } from 'react';\nimport act from './act';\nimport { addToCleanupQueue } from './cleanup';\nimport debugShallow from './helpers/debugShallow';\nimport debugDeep, { DebugOptions } from './helpers/debugDeep';\nimport { getQueriesForElement } from './within';\nimport { setRenderResult, screen } from './screen';\nimport { validateStringsRenderedWithinText } from './helpers/stringValidation';\nimport { getConfig } from './config';\n\nexport type RenderOptions = {\n wrapper?: React.ComponentType<any>;\n createNodeMock?: (element: React.ReactElement) => any;\n unstable_validateStringsRenderedWithinText?: boolean;\n};\n\ntype TestRendererOptions = {\n createNodeMock: (element: React.ReactElement) => any;\n};\n\nexport type RenderResult = ReturnType<typeof render>;\n\n/**\n * Renders test component deeply using react-test-renderer and exposes helpers\n * to assert on the output.\n */\nexport default function render<T>(\n component: React.ReactElement<T>,\n {\n wrapper: Wrapper,\n createNodeMock,\n unstable_validateStringsRenderedWithinText,\n }: RenderOptions = {}\n) {\n if (unstable_validateStringsRenderedWithinText) {\n return renderWithStringValidation(component, {\n wrapper: Wrapper,\n createNodeMock,\n });\n }\n\n const wrap = (element: React.ReactElement) =>\n Wrapper ? <Wrapper>{element}</Wrapper> : element;\n\n const renderer = renderWithAct(\n wrap(component),\n createNodeMock ? { createNodeMock } : undefined\n );\n\n return buildRenderResult(renderer, wrap);\n}\n\nfunction renderWithStringValidation<T>(\n component: React.ReactElement<T>,\n {\n wrapper: Wrapper,\n createNodeMock,\n }: Omit<RenderOptions, 'unstable_validateStringsRenderedWithinText'> = {}\n) {\n const handleRender: React.ProfilerProps['onRender'] = (_, phase) => {\n if (phase === 'update') {\n validateStringsRenderedWithinText(screen.toJSON());\n }\n };\n\n const wrap = (element: React.ReactElement) => (\n <Profiler id=\"renderProfiler\" onRender={handleRender}>\n {Wrapper ? <Wrapper>{element}</Wrapper> : element}\n </Profiler>\n );\n\n const renderer = renderWithAct(\n wrap(component),\n createNodeMock ? { createNodeMock } : undefined\n );\n validateStringsRenderedWithinText(renderer.toJSON());\n\n return buildRenderResult(renderer, wrap);\n}\n\nfunction buildRenderResult(\n renderer: ReactTestRenderer,\n wrap: (element: React.ReactElement) => JSX.Element\n) {\n const update = updateWithAct(renderer, wrap);\n const instance = renderer.root;\n\n const unmount = () => {\n act(() => {\n renderer.unmount();\n });\n };\n\n addToCleanupQueue(unmount);\n\n const result = {\n ...getQueriesForElement(instance),\n update,\n unmount,\n container: instance,\n rerender: update, // alias for `update`\n toJSON: renderer.toJSON,\n debug: debug(instance, renderer),\n };\n\n setRenderResult(result);\n return result;\n}\n\nfunction renderWithAct(\n component: React.ReactElement,\n options?: TestRendererOptions\n): ReactTestRenderer {\n let renderer: ReactTestRenderer;\n\n act(() => {\n renderer = TestRenderer.create(component, options);\n });\n\n // @ts-ignore act is sync, so renderer is always initialised here\n return renderer;\n}\n\nfunction updateWithAct(\n renderer: ReactTestRenderer,\n wrap: (innerElement: React.ReactElement) => React.ReactElement\n) {\n return function (component: React.ReactElement) {\n act(() => {\n renderer.update(wrap(component));\n });\n };\n}\n\ninterface DebugFunction {\n (options?: DebugOptions | string): void;\n shallow: (message?: string) => void;\n}\n\nfunction debug(\n instance: ReactTestInstance,\n renderer: ReactTestRenderer\n): DebugFunction {\n function debugImpl(options?: DebugOptions | string) {\n const { defaultDebugOptions } = getConfig();\n const debugOptions =\n typeof options === 'string'\n ? { ...defaultDebugOptions, message: options }\n : { ...defaultDebugOptions, ...options };\n\n if (typeof options === 'string') {\n // eslint-disable-next-line no-console\n console.warn(\n 'Using debug(\"message\") is deprecated and will be removed in future release, please use debug({ message; \"message\" }) instead.'\n );\n }\n\n const json = renderer.toJSON();\n if (json) {\n return debugDeep(json, debugOptions);\n }\n }\n debugImpl.shallow = (message?: string) => debugShallow(instance, message);\n return debugImpl;\n}\n"],"mappings":"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"}
|
package/build/renderHook.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type RenderHookResult<Result, Props> = {
|
|
3
3
|
rerender: (props: Props) => void;
|
|
4
4
|
result: {
|
|
5
5
|
current: Result;
|
|
6
6
|
};
|
|
7
7
|
unmount: () => void;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type RenderHookOptions<Props> = Props extends object | string | number | boolean ? {
|
|
10
10
|
initialProps: Props;
|
|
11
11
|
wrapper?: ComponentType<any>;
|
|
12
12
|
} : {
|
package/build/renderHook.js
CHANGED
|
@@ -4,31 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.renderHook = renderHook;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _render = _interopRequireDefault(require("./render"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
function renderHook(renderCallback, options) {
|
|
15
11
|
const initialProps = options?.initialProps;
|
|
16
12
|
const wrapper = options?.wrapper;
|
|
17
|
-
|
|
18
13
|
const result = /*#__PURE__*/_react.default.createRef();
|
|
19
|
-
|
|
20
14
|
function TestComponent({
|
|
21
15
|
renderCallbackProps
|
|
22
16
|
}) {
|
|
23
17
|
const renderResult = renderCallback(renderCallbackProps);
|
|
24
|
-
|
|
25
18
|
_react.default.useEffect(() => {
|
|
26
19
|
result.current = renderResult;
|
|
27
20
|
});
|
|
28
|
-
|
|
29
21
|
return null;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
const {
|
|
33
24
|
rerender: baseRerender,
|
|
34
25
|
unmount
|
|
@@ -40,14 +31,13 @@ function renderHook(renderCallback, options) {
|
|
|
40
31
|
}), {
|
|
41
32
|
wrapper
|
|
42
33
|
});
|
|
43
|
-
|
|
44
34
|
function rerender(rerenderCallbackProps) {
|
|
45
35
|
return baseRerender( /*#__PURE__*/_react.default.createElement(TestComponent, {
|
|
46
36
|
renderCallbackProps: rerenderCallbackProps
|
|
47
37
|
}));
|
|
48
|
-
}
|
|
49
|
-
|
|
38
|
+
}
|
|
50
39
|
|
|
40
|
+
// @ts-expect-error result is ill typed because ref is initialized to null
|
|
51
41
|
return {
|
|
52
42
|
result,
|
|
53
43
|
rerender,
|
package/build/renderHook.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderHook.js","names":["renderHook","renderCallback","options","initialProps","wrapper","result","React","createRef","TestComponent","renderCallbackProps","renderResult","useEffect","current","rerender","baseRerender","unmount","render","rerenderCallbackProps"],"sources":["../src/renderHook.tsx"],"sourcesContent":["import React from 'react';\nimport type { ComponentType } from 'react';\nimport render from './render';\n\nexport type RenderHookResult<Result, Props> = {\n rerender: (props: Props) => void;\n result: { current: Result };\n unmount: () => void;\n};\n\nexport type RenderHookOptions<Props> = Props extends\n | object\n | string\n | number\n | boolean\n ? {\n initialProps: Props;\n wrapper?: ComponentType<any>;\n }\n : { wrapper?: ComponentType<any>; initialProps?: never } | undefined;\n\nexport function renderHook<Result, Props>(\n renderCallback: (props: Props) => Result,\n options?: RenderHookOptions<Props>\n): RenderHookResult<Result, Props> {\n const initialProps = options?.initialProps;\n const wrapper = options?.wrapper;\n\n const result: React.MutableRefObject<Result | null> = React.createRef();\n\n function TestComponent({\n renderCallbackProps,\n }: {\n renderCallbackProps: Props;\n }) {\n const renderResult = renderCallback(renderCallbackProps);\n\n React.useEffect(() => {\n result.current = renderResult;\n });\n\n return null;\n }\n\n const { rerender: baseRerender, unmount } = render(\n // @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt\n <TestComponent renderCallbackProps={initialProps} />,\n { wrapper }\n );\n\n function rerender(rerenderCallbackProps: Props) {\n return baseRerender(\n <TestComponent renderCallbackProps={rerenderCallbackProps} />\n );\n }\n\n // @ts-expect-error result is ill typed because ref is initialized to null\n return { result, rerender, unmount };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderHook.js","names":["renderHook","renderCallback","options","initialProps","wrapper","result","React","createRef","TestComponent","renderCallbackProps","renderResult","useEffect","current","rerender","baseRerender","unmount","render","rerenderCallbackProps"],"sources":["../src/renderHook.tsx"],"sourcesContent":["import React from 'react';\nimport type { ComponentType } from 'react';\nimport render from './render';\n\nexport type RenderHookResult<Result, Props> = {\n rerender: (props: Props) => void;\n result: { current: Result };\n unmount: () => void;\n};\n\nexport type RenderHookOptions<Props> = Props extends\n | object\n | string\n | number\n | boolean\n ? {\n initialProps: Props;\n wrapper?: ComponentType<any>;\n }\n : { wrapper?: ComponentType<any>; initialProps?: never } | undefined;\n\nexport function renderHook<Result, Props>(\n renderCallback: (props: Props) => Result,\n options?: RenderHookOptions<Props>\n): RenderHookResult<Result, Props> {\n const initialProps = options?.initialProps;\n const wrapper = options?.wrapper;\n\n const result: React.MutableRefObject<Result | null> = React.createRef();\n\n function TestComponent({\n renderCallbackProps,\n }: {\n renderCallbackProps: Props;\n }) {\n const renderResult = renderCallback(renderCallbackProps);\n\n React.useEffect(() => {\n result.current = renderResult;\n });\n\n return null;\n }\n\n const { rerender: baseRerender, unmount } = render(\n // @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt\n <TestComponent renderCallbackProps={initialProps} />,\n { wrapper }\n );\n\n function rerender(rerenderCallbackProps: Props) {\n return baseRerender(\n <TestComponent renderCallbackProps={rerenderCallbackProps} />\n );\n }\n\n // @ts-expect-error result is ill typed because ref is initialized to null\n return { result, rerender, unmount };\n}\n"],"mappings":";;;;;;AAAA;AAEA;AAA8B;AAmBvB,SAASA,UAAU,CACxBC,cAAwC,EACxCC,OAAkC,EACD;EACjC,MAAMC,YAAY,GAAGD,OAAO,EAAEC,YAAY;EAC1C,MAAMC,OAAO,GAAGF,OAAO,EAAEE,OAAO;EAEhC,MAAMC,MAA6C,gBAAGC,cAAK,CAACC,SAAS,EAAE;EAEvE,SAASC,aAAa,CAAC;IACrBC;EAGF,CAAC,EAAE;IACD,MAAMC,YAAY,GAAGT,cAAc,CAACQ,mBAAmB,CAAC;IAExDH,cAAK,CAACK,SAAS,CAAC,MAAM;MACpBN,MAAM,CAACO,OAAO,GAAGF,YAAY;IAC/B,CAAC,CAAC;IAEF,OAAO,IAAI;EACb;EAEA,MAAM;IAAEG,QAAQ,EAAEC,YAAY;IAAEC;EAAQ,CAAC,GAAG,IAAAC,eAAM;EAAA;EAChD;EACA,6BAAC,aAAa;IAAC,mBAAmB,EAAEb;EAAa,EAAG,EACpD;IAAEC;EAAQ,CAAC,CACZ;EAED,SAASS,QAAQ,CAACI,qBAA4B,EAAE;IAC9C,OAAOH,YAAY,eACjB,6BAAC,aAAa;MAAC,mBAAmB,EAAEG;IAAsB,EAAG,CAC9D;EACH;;EAEA;EACA,OAAO;IAAEZ,MAAM;IAAEQ,QAAQ;IAAEE;EAAQ,CAAC;AACtC"}
|
package/build/screen.js
CHANGED
|
@@ -7,21 +7,17 @@ exports.clearRenderResult = clearRenderResult;
|
|
|
7
7
|
exports.screen = void 0;
|
|
8
8
|
exports.setRenderResult = setRenderResult;
|
|
9
9
|
const SCREEN_ERROR = '`render` method has not been called';
|
|
10
|
-
|
|
11
10
|
const notImplemented = () => {
|
|
12
11
|
throw new Error(SCREEN_ERROR);
|
|
13
12
|
};
|
|
14
|
-
|
|
15
13
|
const notImplementedDebug = () => {
|
|
16
14
|
throw new Error(SCREEN_ERROR);
|
|
17
15
|
};
|
|
18
|
-
|
|
19
16
|
notImplementedDebug.shallow = notImplemented;
|
|
20
17
|
const defaultScreen = {
|
|
21
18
|
get container() {
|
|
22
19
|
throw new Error(SCREEN_ERROR);
|
|
23
20
|
},
|
|
24
|
-
|
|
25
21
|
debug: notImplementedDebug,
|
|
26
22
|
update: notImplemented,
|
|
27
23
|
unmount: notImplemented,
|
|
@@ -116,11 +112,9 @@ const defaultScreen = {
|
|
|
116
112
|
};
|
|
117
113
|
let screen = defaultScreen;
|
|
118
114
|
exports.screen = screen;
|
|
119
|
-
|
|
120
115
|
function setRenderResult(output) {
|
|
121
116
|
exports.screen = screen = output;
|
|
122
117
|
}
|
|
123
|
-
|
|
124
118
|
function clearRenderResult() {
|
|
125
119
|
exports.screen = screen = defaultScreen;
|
|
126
120
|
}
|