@@ -108,14 +108,16 @@ test('getByText, queryByText', () => {
108
108
109
109
expect ( sameButton . props . children ) . toBe ( 'not fresh' ) ;
110
110
expect ( ( ) => getByText ( 'InExistent' ) ) . toThrow (
111
- 'No instances found with text " InExistent" '
111
+ 'Unable to find an element with text: InExistent'
112
112
) ;
113
113
114
114
const zeroText = getByText ( '0' ) ;
115
115
116
116
expect ( queryByText ( / c h a n g e / i) ) . toBe ( button ) ;
117
117
expect ( queryByText ( 'InExistent' ) ) . toBeNull ( ) ;
118
- expect ( ( ) => queryByText ( / f r e s h / ) ) . toThrow ( 'Expected 1 but found 3' ) ;
118
+ expect ( ( ) => queryByText ( / f r e s h / ) ) . toThrow (
119
+ 'Found multiple elements with text: /fresh/'
120
+ ) ;
119
121
expect ( queryByText ( '0' ) ) . toBe ( zeroText ) ;
120
122
} ) ;
121
123
@@ -147,7 +149,9 @@ test('getAllByText, queryAllByText', () => {
147
149
const buttons = getAllByText ( / f r e s h / i) ;
148
150
149
151
expect ( buttons ) . toHaveLength ( 3 ) ;
150
- expect ( ( ) => getAllByText ( 'InExistent' ) ) . toThrow ( 'No instances found' ) ;
152
+ expect ( ( ) => getAllByText ( 'InExistent' ) ) . toThrow (
153
+ 'Unable to find an element with text: InExistent'
154
+ ) ;
151
155
152
156
expect ( queryAllByText ( / f r e s h / i) ) . toEqual ( buttons ) ;
153
157
expect ( queryAllByText ( 'InExistent' ) ) . toHaveLength ( 0 ) ;
@@ -163,13 +167,13 @@ test('getByPlaceholderText, queryByPlaceholderText', () => {
163
167
164
168
expect ( sameInput . props . placeholder ) . toBe ( PLACEHOLDER_FRESHNESS ) ;
165
169
expect ( ( ) => getByPlaceholderText ( 'no placeholder' ) ) . toThrow (
166
- 'No instances found with placeholder " no placeholder" '
170
+ 'Unable to find an element with placeholder: no placeholder'
167
171
) ;
168
172
169
173
expect ( queryByPlaceholderText ( / a d d / i) ) . toBe ( input ) ;
170
174
expect ( queryByPlaceholderText ( 'no placeholder' ) ) . toBeNull ( ) ;
171
175
expect ( ( ) => queryByPlaceholderText ( / f r e s h / ) ) . toThrow (
172
- 'Expected 1 but found 2 '
176
+ 'Found multiple elements with placeholder: /fresh/ '
173
177
) ;
174
178
} ) ;
175
179
@@ -181,7 +185,7 @@ test('getAllByPlaceholderText, queryAllByPlaceholderText', () => {
181
185
182
186
expect ( inputs ) . toHaveLength ( 2 ) ;
183
187
expect ( ( ) => getAllByPlaceholderText ( 'no placeholder' ) ) . toThrow (
184
- 'No instances found '
188
+ 'Unable to find an element with placeholder: no placeholder '
185
189
) ;
186
190
187
191
expect ( queryAllByPlaceholderText ( / f r e s h / i) ) . toEqual ( inputs ) ;
@@ -198,12 +202,14 @@ test('getByDisplayValue, queryByDisplayValue', () => {
198
202
199
203
expect ( sameInput . props . value ) . toBe ( INPUT_FRESHNESS ) ;
200
204
expect ( ( ) => getByDisplayValue ( 'no value' ) ) . toThrow (
201
- 'No instances found with display value " no value" '
205
+ 'Unable to find an element with displayValue: no value'
202
206
) ;
203
207
204
208
expect ( queryByDisplayValue ( / c u s t o m / i) ) . toBe ( input ) ;
205
209
expect ( queryByDisplayValue ( 'no value' ) ) . toBeNull ( ) ;
206
- expect ( ( ) => queryByDisplayValue ( / f r e s h / i) ) . toThrow ( 'Expected 1 but found 2' ) ;
210
+ expect ( ( ) => queryByDisplayValue ( / f r e s h / i) ) . toThrow (
211
+ 'Found multiple elements with display value: /fresh/i'
212
+ ) ;
207
213
} ) ;
208
214
209
215
test ( 'getByDisplayValue, queryByDisplayValue get element by default value only when value is undefined' , ( ) => {
@@ -223,7 +229,9 @@ test('getAllByDisplayValue, queryAllByDisplayValue', () => {
223
229
const inputs = getAllByDisplayValue ( / f r e s h / i) ;
224
230
225
231
expect ( inputs ) . toHaveLength ( 2 ) ;
226
- expect ( ( ) => getAllByDisplayValue ( 'no value' ) ) . toThrow ( 'No instances found' ) ;
232
+ expect ( ( ) => getAllByDisplayValue ( 'no value' ) ) . toThrow (
233
+ 'Unable to find an element with displayValue: no value'
234
+ ) ;
227
235
228
236
expect ( queryAllByDisplayValue ( / f r e s h / i) ) . toEqual ( inputs ) ;
229
237
expect ( queryAllByDisplayValue ( 'no value' ) ) . toHaveLength ( 0 ) ;
0 commit comments