@@ -72,7 +72,9 @@ test(`should not suggest if the suggestion would give different results`, () =>
72
72
test ( 'should suggest by label over title' , ( ) => {
73
73
renderIntoDocument ( `<label><span>bar</span><input title="foo" /></label>` )
74
74
75
- expect ( ( ) => screen . getByTitle ( 'foo' ) ) . toThrowError ( / g e t B y L a b e l T e x t \( ' b a r ' \) / )
75
+ expect ( ( ) => screen . getByTitle ( 'foo' ) ) . toThrowError (
76
+ / g e t B y L a b e l T e x t \( \/ b a r \/ i \) / ,
77
+ )
76
78
} )
77
79
78
80
test ( 'should not suggest if there would be mixed suggestions' , ( ) => {
@@ -178,7 +180,7 @@ test('should suggest getByLabelText when no role available', () => {
178
180
`<label for="foo">Username</label><input data-testid="foo" id="foo" />` ,
179
181
)
180
182
expect ( ( ) => screen . getByTestId ( 'foo' ) ) . toThrowError (
181
- / g e t B y L a b e l T e x t \( ' U s e r n a m e ' \) / ,
183
+ / g e t B y L a b e l T e x t \( \/ u s e r n a m e \/ i \) / ,
182
184
)
183
185
} )
184
186
@@ -191,7 +193,7 @@ test(`should suggest getByLabel on non form elements`, () => {
191
193
` )
192
194
193
195
expect ( ( ) => screen . getByTestId ( 'foo' ) ) . toThrowError (
194
- / g e t B y L a b e l T e x t \( ' S e c t i o n O n e ' \) / ,
196
+ / g e t B y L a b e l T e x t \( \/ s e c t i o n o n e \/ i \) / ,
195
197
)
196
198
} )
197
199
@@ -230,23 +232,23 @@ test(`should suggest label over placeholder text`, () => {
230
232
)
231
233
232
234
expect ( ( ) => screen . getByPlaceholderText ( 'Username' ) ) . toThrowError (
233
- / g e t B y L a b e l T e x t \( ' U s e r n a m e ' \) / ,
235
+ / g e t B y L a b e l T e x t \( \/ u s e r n a m e \/ i \) / ,
234
236
)
235
237
} )
236
238
237
239
test ( `should suggest getByPlaceholderText` , ( ) => {
238
240
renderIntoDocument ( `<input data-testid="foo" placeholder="Username" />` )
239
241
240
242
expect ( ( ) => screen . getByTestId ( 'foo' ) ) . toThrowError (
241
- / g e t B y P l a c e h o l d e r T e x t \( ' U s e r n a m e ' \) / ,
243
+ / g e t B y P l a c e h o l d e r T e x t \( \/ u s e r n a m e \/ i \) / ,
242
244
)
243
245
} )
244
246
245
247
test ( `should suggest getByText for simple elements` , ( ) => {
246
248
renderIntoDocument ( `<div data-testid="foo">hello there</div>` )
247
249
248
250
expect ( ( ) => screen . getByTestId ( 'foo' ) ) . toThrowError (
249
- / g e t B y T e x t \( ' h e l l o t h e r e ' \) / ,
251
+ / g e t B y T e x t \( \/ h e l l o t h e r e \/ i \) / ,
250
252
)
251
253
} )
252
254
@@ -256,7 +258,7 @@ test(`should suggest getByDisplayValue`, () => {
256
258
document . getElementById ( 'lastName' ) . value = 'Prine' // RIP John Prine
257
259
258
260
expect ( ( ) => screen . getByTestId ( 'lastName' ) ) . toThrowError (
259
- / g e t B y D i s p l a y V a l u e \( ' P r i n e ' \) / ,
261
+ / g e t B y D i s p l a y V a l u e \( \/ p r i n e \/ i \) / ,
260
262
)
261
263
} )
262
264
@@ -269,10 +271,10 @@ test(`should suggest getByAltText`, () => {
269
271
` )
270
272
271
273
expect ( ( ) => screen . getByTestId ( 'input' ) ) . toThrowError (
272
- / g e t B y A l t T e x t \( ' l a s t n a m e ' \) / ,
274
+ / g e t B y A l t T e x t \( \/ l a s t n a m e \/ i \) / ,
273
275
)
274
276
expect ( ( ) => screen . getByTestId ( 'area' ) ) . toThrowError (
275
- / g e t B y A l t T e x t \( ' C o m p u t e r ' \) / ,
277
+ / g e t B y A l t T e x t \( \/ c o m p u t e r \/ i \) / ,
276
278
)
277
279
} )
278
280
@@ -285,27 +287,29 @@ test(`should suggest getByTitle`, () => {
285
287
</svg>` )
286
288
287
289
expect ( ( ) => screen . getByTestId ( 'delete' ) ) . toThrowError (
288
- / g e t B y T i t l e \( ' D e l e t e ' \) / ,
290
+ / g e t B y T i t l e \( \/ d e l e t e \/ i \) / ,
289
291
)
290
292
expect ( ( ) => screen . getAllByTestId ( 'delete' ) ) . toThrowError (
291
- / g e t A l l B y T i t l e \( ' D e l e t e ' \) / ,
293
+ / g e t A l l B y T i t l e \( \/ d e l e t e \/ i \) / ,
292
294
)
293
295
expect ( ( ) => screen . queryByTestId ( 'delete' ) ) . toThrowError (
294
- / q u e r y B y T i t l e \( ' D e l e t e ' \) / ,
296
+ / q u e r y B y T i t l e \( \/ d e l e t e \/ i \) / ,
295
297
)
296
298
expect ( ( ) => screen . queryAllByTestId ( 'delete' ) ) . toThrowError (
297
- / q u e r y A l l B y T i t l e \( ' D e l e t e ' \) / ,
299
+ / q u e r y A l l B y T i t l e \( \/ d e l e t e \/ i \) / ,
298
300
)
299
301
expect ( ( ) => screen . queryAllByTestId ( 'delete' ) ) . toThrowError (
300
- / q u e r y A l l B y T i t l e \( ' D e l e t e ' \) / ,
302
+ / q u e r y A l l B y T i t l e \( \/ d e l e t e \/ i \) / ,
301
303
)
302
304
expect ( ( ) => screen . queryAllByTestId ( 'delete' ) ) . toThrowError (
303
- / q u e r y A l l B y T i t l e \( ' D e l e t e ' \) / ,
305
+ / q u e r y A l l B y T i t l e \( \/ d e l e t e \/ i \) / ,
304
306
)
305
307
306
308
// Since `ByTitle` and `ByText` will both return the <title> element
307
309
// `getByText` will always be the suggested query as it is higher up the list.
308
- expect ( ( ) => screen . getByTestId ( 'svg' ) ) . toThrowError ( / g e t B y T e x t \( ' C l o s e ' \) / )
310
+ expect ( ( ) => screen . getByTestId ( 'svg' ) ) . toThrowError (
311
+ / g e t B y T e x t \( \/ c l o s e \/ i \) / ,
312
+ )
309
313
} )
310
314
311
315
test ( 'getSuggestedQuery handles `variant` and defaults to `get`' , ( ) => {
@@ -343,9 +347,9 @@ test('getSuggestedQuery returns rich data for tooling', () => {
343
347
expect ( getSuggestedQuery ( div ) ) . toMatchObject ( {
344
348
queryName : 'Text' ,
345
349
queryMethod : 'getByText' ,
346
- queryArgs : [ ' cancel' ] ,
350
+ queryArgs : [ / c a n c e l / i ] ,
347
351
variant : 'get' ,
348
352
} )
349
353
350
- expect ( getSuggestedQuery ( div ) . toString ( ) ) . toEqual ( `getByText(' cancel' )` )
354
+ expect ( getSuggestedQuery ( div ) . toString ( ) ) . toEqual ( `getByText(/ cancel/i )` )
351
355
} )
0 commit comments