File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -462,3 +462,20 @@ You can query a specific element like this
462
462
``` js
463
463
getByRole (' alertdialog' , {description: ' Your session is about to expire' })
464
464
```
465
+
466
+ ## Performance
467
+
468
+ ` getByRole ` is the most preferred query to use as it most closely resembles the
469
+ user experience, however the calculations it must perform to provide this
470
+ confidence can be expensive (particularly with large DOM trees).
471
+
472
+ Where test performance is a concern it may be desirable to trade some of this
473
+ confidence for improved performance.
474
+
475
+ ` getByRole ` performance can be improved by setting the option
476
+ [ ` hidden ` ] ( #hidden ) to ` true ` and thereby avoid expensive visibility checks.
477
+ Note that in doing so inaccessible elements will now be included in the result.
478
+
479
+ Another option may be to substitute ` getByRole ` for simpler ` getByLabelText ` and
480
+ ` getByText ` queries which can be significantly faster though less robust
481
+ alternatives.
You can’t perform that action at this time.
0 commit comments