Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Slow getByRole leads to test timeouts

Abierto
#1,213 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
javascript, react

Línea de trabajo

Comienza con la reproducción enlazada de Testing Playground y el punto de entrada getByRole indicado; después, perfila las llamadas repetidas usando el render proporcionado al estilo de Ant Design. Compara el tiempo de ejecución actual con los aproximadamente 1,6 segundos por llamada reportados; se considera terminado cuando la reproducción ya no provoca tiempos de espera agotados en las pruebas sin cambiar el comportamiento previsto de la prueba.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

  • @testing-library/react version: 13.4.0
  • Testing Framework and version: "@nrwl/jest": "14.8.6"
  • DOM Environment: "@testing-library/jest-dom": "5.16.5"
Relevant code or config:
instance.getByRole('button', {
  name: 'tests.actions.add', hidden: true
  })
).toBeEnabled();
What you did:

I create rederresult with act<RenderResult> and try to find some elements on the screen.

This, with other buttons, is called like 6 times in this one test

What happened:

We migrate our code from andt4 to antd5. As we did this we noticed a lot of our test time out. They time out, because getByRole() takes a lot of time. Sure, Antd is part of the problem, but the rendered result is a rendered result and that should work. The Test, I send in the reproduction part, is just rendering, with some fetchMocks, so no UI changes after the setup.

Reproduction:

I tried to create a good reproduction, but with all our setup code, its complex. So I created a playground with the actual screen render.

https://testing-playground.com/gist/dcc46780eeacb3579d7b790f7fb4e577/c9e236ee04cfd77a19d8bb773e295010ed319ddb

Problem description:

getByRole() takes a lot of time in this jest test. I used the profiler to get a feeling, on how long.

Profiler

As you can see, for one getByRole() it takes around 1.6second. This adds up and leads to tests, that time out.

Suggested solution:

make getByRole fast 😅 I read a lot in the past weeks and someone said, this is slow (coudn't find the Issue again, sorry). I guess this could be improved.

cc @MLB00N

Lenguaje dominante
JavaScript
Estrellas
19.7k
Forks
1.2k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de testing-library/react-testing-library

Todos los issues de testing-library/react-testing-library

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.