@@ -91,7 +91,7 @@ export function assertMenuButton(
91
91
expect ( button ) . toHaveAttribute ( attributeName , options . attributes [ attributeName ] )
92
92
}
93
93
} catch ( err ) {
94
- Error . captureStackTrace ( err , assertMenuButton )
94
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertMenuButton )
95
95
throw err
96
96
}
97
97
}
@@ -105,7 +105,7 @@ export function assertMenuButtonLinkedWithMenu(button = getMenuButton(), menu =
105
105
expect ( button ) . toHaveAttribute ( 'aria-controls' , menu . getAttribute ( 'id' ) )
106
106
expect ( menu ) . toHaveAttribute ( 'aria-labelledby' , button . getAttribute ( 'id' ) )
107
107
} catch ( err ) {
108
- Error . captureStackTrace ( err , assertMenuButtonLinkedWithMenu )
108
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertMenuButtonLinkedWithMenu )
109
109
throw err
110
110
}
111
111
}
@@ -118,7 +118,7 @@ export function assertMenuLinkedWithMenuItem(item: HTMLElement | null, menu = ge
118
118
// Ensure link between menu & menu item is correct
119
119
expect ( menu ) . toHaveAttribute ( 'aria-activedescendant' , item . getAttribute ( 'id' ) )
120
120
} catch ( err ) {
121
- Error . captureStackTrace ( err , assertMenuLinkedWithMenuItem )
121
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertMenuLinkedWithMenuItem )
122
122
throw err
123
123
}
124
124
}
@@ -130,7 +130,7 @@ export function assertNoActiveMenuItem(menu = getMenu()) {
130
130
// Ensure we don't have an active menu
131
131
expect ( menu ) . not . toHaveAttribute ( 'aria-activedescendant' )
132
132
} catch ( err ) {
133
- Error . captureStackTrace ( err , assertNoActiveMenuItem )
133
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertNoActiveMenuItem )
134
134
throw err
135
135
}
136
136
}
@@ -183,7 +183,7 @@ export function assertMenu(
183
183
assertNever ( options . state )
184
184
}
185
185
} catch ( err ) {
186
- Error . captureStackTrace ( err , assertMenu )
186
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertMenu )
187
187
throw err
188
188
}
189
189
}
@@ -214,7 +214,7 @@ export function assertMenuItem(
214
214
}
215
215
}
216
216
} catch ( err ) {
217
- Error . captureStackTrace ( err , assertMenuItem )
217
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertMenuItem )
218
218
throw err
219
219
}
220
220
}
@@ -311,7 +311,7 @@ export function assertListbox(
311
311
assertNever ( options . state )
312
312
}
313
313
} catch ( err ) {
314
- Error . captureStackTrace ( err , assertListbox )
314
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertListbox )
315
315
throw err
316
316
}
317
317
}
@@ -368,7 +368,7 @@ export function assertListboxButton(
368
368
expect ( button ) . toHaveAttribute ( attributeName , options . attributes [ attributeName ] )
369
369
}
370
370
} catch ( err ) {
371
- Error . captureStackTrace ( err , assertListboxButton )
371
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertListboxButton )
372
372
throw err
373
373
}
374
374
}
@@ -400,7 +400,7 @@ export function assertListboxLabel(
400
400
expect ( label ) . toHaveAttribute ( attributeName , options . attributes [ attributeName ] )
401
401
}
402
402
} catch ( err ) {
403
- Error . captureStackTrace ( err , assertListboxLabel )
403
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertListboxLabel )
404
404
throw err
405
405
}
406
406
}
@@ -417,7 +417,7 @@ export function assertListboxButtonLinkedWithListbox(
417
417
expect ( button ) . toHaveAttribute ( 'aria-controls' , listbox . getAttribute ( 'id' ) )
418
418
expect ( listbox ) . toHaveAttribute ( 'aria-labelledby' , button . getAttribute ( 'id' ) )
419
419
} catch ( err ) {
420
- Error . captureStackTrace ( err , assertListboxButtonLinkedWithListbox )
420
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertListboxButtonLinkedWithListbox )
421
421
throw err
422
422
}
423
423
}
@@ -432,7 +432,7 @@ export function assertListboxLabelLinkedWithListbox(
432
432
433
433
expect ( listbox ) . toHaveAttribute ( 'aria-labelledby' , label . getAttribute ( 'id' ) )
434
434
} catch ( err ) {
435
- Error . captureStackTrace ( err , assertListboxLabelLinkedWithListbox )
435
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertListboxLabelLinkedWithListbox )
436
436
throw err
437
437
}
438
438
}
@@ -448,7 +448,8 @@ export function assertListboxButtonLinkedWithListboxLabel(
448
448
// Ensure link between button & label is correct
449
449
expect ( button ) . toHaveAttribute ( 'aria-labelledby' , `${ label . id } ${ button . id } ` )
450
450
} catch ( err ) {
451
- Error . captureStackTrace ( err , assertListboxButtonLinkedWithListboxLabel )
451
+ if ( err instanceof Error )
452
+ Error . captureStackTrace ( err , assertListboxButtonLinkedWithListboxLabel )
452
453
throw err
453
454
}
454
455
}
@@ -461,7 +462,7 @@ export function assertActiveListboxOption(item: HTMLElement | null, listbox = ge
461
462
// Ensure link between listbox & listbox item is correct
462
463
expect ( listbox ) . toHaveAttribute ( 'aria-activedescendant' , item . getAttribute ( 'id' ) )
463
464
} catch ( err ) {
464
- Error . captureStackTrace ( err , assertActiveListboxOption )
465
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertActiveListboxOption )
465
466
throw err
466
467
}
467
468
}
@@ -473,7 +474,7 @@ export function assertNoActiveListboxOption(listbox = getListbox()) {
473
474
// Ensure we don't have an active listbox
474
475
expect ( listbox ) . not . toHaveAttribute ( 'aria-activedescendant' )
475
476
} catch ( err ) {
476
- Error . captureStackTrace ( err , assertNoActiveListboxOption )
477
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertNoActiveListboxOption )
477
478
throw err
478
479
}
479
480
}
@@ -482,7 +483,7 @@ export function assertNoSelectedListboxOption(items = getListboxOptions()) {
482
483
try {
483
484
for ( let item of items ) expect ( item ) . not . toHaveAttribute ( 'aria-selected' )
484
485
} catch ( err ) {
485
- Error . captureStackTrace ( err , assertNoSelectedListboxOption )
486
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertNoSelectedListboxOption )
486
487
throw err
487
488
}
488
489
}
@@ -530,7 +531,7 @@ export function assertListboxOption(
530
531
}
531
532
}
532
533
} catch ( err ) {
533
- Error . captureStackTrace ( err , assertListboxOption )
534
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertListboxOption )
534
535
throw err
535
536
}
536
537
}
@@ -597,7 +598,7 @@ export function assertSwitch(
597
598
assertNever ( options . state )
598
599
}
599
600
} catch ( err ) {
600
- Error . captureStackTrace ( err , assertSwitch )
601
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertSwitch )
601
602
throw err
602
603
}
603
604
}
@@ -678,7 +679,7 @@ export function assertDisclosureButton(
678
679
expect ( button ) . toHaveAttribute ( attributeName , options . attributes [ attributeName ] )
679
680
}
680
681
} catch ( err ) {
681
- Error . captureStackTrace ( err , assertDisclosureButton )
682
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertDisclosureButton )
682
683
throw err
683
684
}
684
685
}
@@ -725,7 +726,7 @@ export function assertDisclosurePanel(
725
726
assertNever ( options . state )
726
727
}
727
728
} catch ( err ) {
728
- Error . captureStackTrace ( err , assertDisclosurePanel )
729
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertDisclosurePanel )
729
730
throw err
730
731
}
731
732
}
@@ -810,7 +811,7 @@ export function assertPopoverButton(
810
811
expect ( button ) . toHaveAttribute ( attributeName , options . attributes [ attributeName ] )
811
812
}
812
813
} catch ( err ) {
813
- Error . captureStackTrace ( err , assertPopoverButton )
814
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertPopoverButton )
814
815
throw err
815
816
}
816
817
}
@@ -857,7 +858,7 @@ export function assertPopoverPanel(
857
858
assertNever ( options . state )
858
859
}
859
860
} catch ( err ) {
860
- Error . captureStackTrace ( err , assertPopoverPanel )
861
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertPopoverPanel )
861
862
throw err
862
863
}
863
864
}
@@ -984,7 +985,7 @@ export function assertDialog(
984
985
assertNever ( options . state )
985
986
}
986
987
} catch ( err ) {
987
- Error . captureStackTrace ( err , assertDialog )
988
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertDialog )
988
989
throw err
989
990
}
990
991
}
@@ -1040,7 +1041,7 @@ export function assertDialogTitle(
1040
1041
assertNever ( options . state )
1041
1042
}
1042
1043
} catch ( err ) {
1043
- Error . captureStackTrace ( err , assertDialogTitle )
1044
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertDialogTitle )
1044
1045
throw err
1045
1046
}
1046
1047
}
@@ -1096,7 +1097,7 @@ export function assertDialogDescription(
1096
1097
assertNever ( options . state )
1097
1098
}
1098
1099
} catch ( err ) {
1099
- Error . captureStackTrace ( err , assertDialogDescription )
1100
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertDialogDescription )
1100
1101
throw err
1101
1102
}
1102
1103
}
@@ -1143,7 +1144,7 @@ export function assertDialogOverlay(
1143
1144
assertNever ( options . state )
1144
1145
}
1145
1146
} catch ( err ) {
1146
- Error . captureStackTrace ( err , assertDialogOverlay )
1147
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertDialogOverlay )
1147
1148
throw err
1148
1149
}
1149
1150
}
@@ -1185,7 +1186,7 @@ export function assertRadioGroupLabel(
1185
1186
expect ( label ) . toHaveAttribute ( attributeName , options . attributes [ attributeName ] )
1186
1187
}
1187
1188
} catch ( err ) {
1188
- Error . captureStackTrace ( err , assertRadioGroupLabel )
1189
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertRadioGroupLabel )
1189
1190
throw err
1190
1191
}
1191
1192
}
@@ -1267,7 +1268,7 @@ export function assertTabs(
1267
1268
}
1268
1269
}
1269
1270
} catch ( err ) {
1270
- Error . captureStackTrace ( err , assertTabs )
1271
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertTabs )
1271
1272
throw err
1272
1273
}
1273
1274
}
@@ -1287,7 +1288,7 @@ export function assertActiveElement(element: HTMLElement | null) {
1287
1288
expect ( document . activeElement ?. outerHTML ) . toBe ( element . outerHTML )
1288
1289
}
1289
1290
} catch ( err ) {
1290
- Error . captureStackTrace ( err , assertActiveElement )
1291
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertActiveElement )
1291
1292
throw err
1292
1293
}
1293
1294
}
@@ -1297,7 +1298,7 @@ export function assertContainsActiveElement(element: HTMLElement | null) {
1297
1298
if ( element === null ) return expect ( element ) . not . toBe ( null )
1298
1299
expect ( element . contains ( document . activeElement ) ) . toBe ( true )
1299
1300
} catch ( err ) {
1300
- Error . captureStackTrace ( err , assertContainsActiveElement )
1301
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertContainsActiveElement )
1301
1302
throw err
1302
1303
}
1303
1304
}
@@ -1311,7 +1312,7 @@ export function assertHidden(element: HTMLElement | null) {
1311
1312
expect ( element ) . toHaveAttribute ( 'hidden' )
1312
1313
expect ( element ) . toHaveStyle ( { display : 'none' } )
1313
1314
} catch ( err ) {
1314
- Error . captureStackTrace ( err , assertHidden )
1315
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertHidden )
1315
1316
throw err
1316
1317
}
1317
1318
}
@@ -1323,7 +1324,7 @@ export function assertVisible(element: HTMLElement | null) {
1323
1324
expect ( element ) . not . toHaveAttribute ( 'hidden' )
1324
1325
expect ( element ) . not . toHaveStyle ( { display : 'none' } )
1325
1326
} catch ( err ) {
1326
- Error . captureStackTrace ( err , assertVisible )
1327
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertVisible )
1327
1328
throw err
1328
1329
}
1329
1330
}
@@ -1336,7 +1337,7 @@ export function assertFocusable(element: HTMLElement | null) {
1336
1337
1337
1338
expect ( isFocusableElement ( element , FocusableMode . Strict ) ) . toBe ( true )
1338
1339
} catch ( err ) {
1339
- Error . captureStackTrace ( err , assertFocusable )
1340
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertFocusable )
1340
1341
throw err
1341
1342
}
1342
1343
}
@@ -1347,7 +1348,7 @@ export function assertNotFocusable(element: HTMLElement | null) {
1347
1348
1348
1349
expect ( isFocusableElement ( element , FocusableMode . Strict ) ) . toBe ( false )
1349
1350
} catch ( err ) {
1350
- Error . captureStackTrace ( err , assertNotFocusable )
1351
+ if ( err instanceof Error ) Error . captureStackTrace ( err , assertNotFocusable )
1351
1352
throw err
1352
1353
}
1353
1354
}
0 commit comments