@@ -108,14 +108,16 @@ test('getByText, queryByText', () => {
108108
109109 expect ( sameButton . props . children ) . toBe ( 'not fresh' ) ;
110110 expect ( ( ) => getByText ( 'InExistent' ) ) . toThrow (
111- 'No instances found with text " InExistent" '
111+ 'Unable to find an element with text: InExistent'
112112 ) ;
113113
114114 const zeroText = getByText ( '0' ) ;
115115
116116 expect ( queryByText ( / c h a n g e / i) ) . toBe ( button ) ;
117117 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+ ) ;
119121 expect ( queryByText ( '0' ) ) . toBe ( zeroText ) ;
120122} ) ;
121123
@@ -147,7 +149,9 @@ test('getAllByText, queryAllByText', () => {
147149 const buttons = getAllByText ( / f r e s h / i) ;
148150
149151 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+ ) ;
151155
152156 expect ( queryAllByText ( / f r e s h / i) ) . toEqual ( buttons ) ;
153157 expect ( queryAllByText ( 'InExistent' ) ) . toHaveLength ( 0 ) ;
@@ -163,13 +167,13 @@ test('getByPlaceholderText, queryByPlaceholderText', () => {
163167
164168 expect ( sameInput . props . placeholder ) . toBe ( PLACEHOLDER_FRESHNESS ) ;
165169 expect ( ( ) => getByPlaceholderText ( 'no placeholder' ) ) . toThrow (
166- 'No instances found with placeholder " no placeholder" '
170+ 'Unable to find an element with placeholder: no placeholder'
167171 ) ;
168172
169173 expect ( queryByPlaceholderText ( / a d d / i) ) . toBe ( input ) ;
170174 expect ( queryByPlaceholderText ( 'no placeholder' ) ) . toBeNull ( ) ;
171175 expect ( ( ) => queryByPlaceholderText ( / f r e s h / ) ) . toThrow (
172- 'Expected 1 but found 2 '
176+ 'Found multiple elements with placeholder: /fresh/ '
173177 ) ;
174178} ) ;
175179
@@ -181,7 +185,7 @@ test('getAllByPlaceholderText, queryAllByPlaceholderText', () => {
181185
182186 expect ( inputs ) . toHaveLength ( 2 ) ;
183187 expect ( ( ) => getAllByPlaceholderText ( 'no placeholder' ) ) . toThrow (
184- 'No instances found '
188+ 'Unable to find an element with placeholder: no placeholder '
185189 ) ;
186190
187191 expect ( queryAllByPlaceholderText ( / f r e s h / i) ) . toEqual ( inputs ) ;
@@ -198,12 +202,14 @@ test('getByDisplayValue, queryByDisplayValue', () => {
198202
199203 expect ( sameInput . props . value ) . toBe ( INPUT_FRESHNESS ) ;
200204 expect ( ( ) => getByDisplayValue ( 'no value' ) ) . toThrow (
201- 'No instances found with display value " no value" '
205+ 'Unable to find an element with displayValue: no value'
202206 ) ;
203207
204208 expect ( queryByDisplayValue ( / c u s t o m / i) ) . toBe ( input ) ;
205209 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+ ) ;
207213} ) ;
208214
209215test ( 'getByDisplayValue, queryByDisplayValue get element by default value only when value is undefined' , ( ) => {
@@ -223,7 +229,9 @@ test('getAllByDisplayValue, queryAllByDisplayValue', () => {
223229 const inputs = getAllByDisplayValue ( / f r e s h / i) ;
224230
225231 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+ ) ;
227235
228236 expect ( queryAllByDisplayValue ( / f r e s h / i) ) . toEqual ( inputs ) ;
229237 expect ( queryAllByDisplayValue ( 'no value' ) ) . toHaveLength ( 0 ) ;
0 commit comments