title: React-testing-library getByRole is performing extremely slowly
body: <p>We have noticed that our unit tests are performing very slowly and the culprit seems to be <code>getByRole</code> for querying for button elements etc. Here is an example of a query that was giving us problems today:</p>
  <pre><code>userEvent.click(screen.getAllByRole('button', { name: 'Accept' })[0]);
  </code></pre>
  <p>Using <code>console.time()</code> we measured this query as taking 12782ms to execute. After switching to <code>getByText</code> the query takes 14ms, meaning that <code>getByRole</code> is taking nearly 1000x longer (!!!).</p>
  <p>I know that <code>getByRole</code> is expected to run slower, but it seems extreme. I've found threads online detailing how some tests took 5x longer but nothing like this. Adding <code>hidden: true</code> as an option speeds things up a little but not by a massive amount.</p>
  <p>I'm unable to share the code that is being tested as it is private. I wouldn't describe the component as particularly complex, although it is comprised of a few lower-level components and uses mocked out network requests.</p>
  <p>Are there any known reasons for slow running queries like this, or any ways we can speed up execution without sacrificing the confidence that <code>getByRole</code> offers?</p>