Test based on `findByText` assertion fails after 551ms, despite default timeout being 1000ms
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript, react, typescript
- Área
- testing-qa
Línea de trabajo
Comienza con la aserción screen.findByText proporcionada y las versiones indicadas de @testing-library/react 16.3.0, Vitest 3.2.4 y jsdom 26.1.0. Investiga, usando como contexto la documentación enlazada de findBy y el issue anterior, si el fallo alcanza el tiempo de espera documentado de 1000ms o si Vitest informa de la duración de forma inexacta. Se considera completado cuando se identifica el origen del fallo temprano intermitente o se documenta que es externo.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
@testing-library/reactversion: 16.3.0- Testing Framework and version: Vitest 3.2.4
- DOM Environment: jsdom 26.1.0
Relevant code or config:
expect(
await screen.findByText(
"text which is supposed to be found after loading state is passed",
),
).toBeInTheDocument();
What you did:
Ran a test which failed on this assertion. Only sometimes. Typically in CI (Github Actions).
What happened:
× path/to/my.test.tsx > x > shows expected content 551ms
→ expect(element).toBeInTheDocument()
element could not be found in the document
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯
FAIL path/to/my.test.tsx > x > shows expected content
Error: expect(element).toBeInTheDocument()
element could not be found in the document
Reproduction:
Does not reproduce easily. Is flaky. Trying to understand if there is some misunderstanding in how things are supposed to work.
Problem description:
When running a test based on findBy, we sometimes find them to be flaky. It is sometimes resolved by using waitForElementToBeRemoved on the previous state, but that just adds another possible race condition, and also tends to be flaky.
I expect the test to run for at least 1000ms (as per findBy logic documented here), but sometimes find that the test fails much sooner (after 551 ms in the example above).
Suggested solution:
I'm trying to deduce a cause here for further investigation.
- Is
findByresolving sooner than expected? If yes, it seems like a problem internal to the library, possibly https://github.com/testing-library/react-testing-library/issues/865? - Is the (vitest) reported time unreliable, and we may have hit the 1000ms timeout despite 551ms being reported? If so, maybe extending the default timeout could be beneficial, even though hundreds of similar tests tend to pass every time, so it seems odd.
Overall, this seems like a strange problem, and I'm not expecting a straight-forward fix, but would like you to know about it, and would be grateful for any pointers on how to analyze further.
- Lenguaje dominante
- JavaScript
- Estrellas
- 19.7k
- Forks
- 1.2k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de testing-library/react-testing-library
-
fireEvent.select does not wrap its automatic native focus in actPosiblemente ocupada @sergioperezcheco la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
bug: calling configure() without reactStrictMode resets it to undefined, silently disabling strict modeQuizá libre de nuevo @suhailopensource la tomó hace 72 días y no hay ningún pull request abierto. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
testing-library/react-testing-library#1466 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
testing-library/react-testing-library#1459 · 2 comentarios ·
-
perf: optimize container lookup with early exitQuizá libre de nuevo @Ch-Abhinav-Chowdary la tomó hace 298 días y no hay ningún pull request abierto. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 35/100
testing-library/react-testing-library#1430 · 1 comentario ·
-
`fireEvent.mouseEnter` does not forward `relatedTarget` (relatedTarget is the window instead)Posiblemente ocupada @swarnim02 la tomó hace 315 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
Todos los issues de testing-library/react-testing-library
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
NaturalIntelligence/fast-xml-parser#888 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
bug callouts regression revealjs
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
quarto-dev/quarto-cli#15014 ·
Los mantenedores suelen responder en 1 día
-
Remove: Fox Deportes SDAbiertocheck:passed feeds:remove
Dificultad 1/5 Menos de una hora Aptitud para principiantes 65/100
iptv-org/database#37176 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 9 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
hawk-digital-environments/HAWKI#443 ·
Los mantenedores suelen responder en 1 día
-
documentation v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
modelcontextprotocol/python-sdk#3662 ·
Los mantenedores suelen responder en 1 día