Test based on `findByText` assertion fails after 551ms, despite default timeout being 1000ms
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- À clarifier
- Activité
- À l'abandon
- Stack technique
- javascript, react, typescript
- Domaine
- testing-qa
Piste de recherche
Commencez par l’assertion screen.findByText fournie et par les versions indiquées de @testing-library/react 16.3.0, Vitest 3.2.4 et jsdom 26.1.0. Cherchez à déterminer, en vous appuyant sur la documentation findBy liée et sur l’issue précédente comme contexte, si l’échec atteint le délai d’expiration documenté de 1000ms ou si Vitest signale la durée de manière inexacte. Le travail est terminé lorsque la source de l’échec précoce intermittent est identifiée ou qu’il est documenté qu’il est externe.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
@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.
- Langage dominant
- JavaScript
- Étoiles
- 19.7k
- Forks
- 1.2k
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de testing-library/react-testing-library
-
fireEvent.select does not wrap its automatic native focus in actPeut-être pris @sergioperezcheco l’a pris il y a 26 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
-
bug: calling configure() without reactStrictMode resets it to undefined, silently disabling strict modePeut-être pris @nimbly1 l’a pris il y a 6 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 35/100
testing-library/react-testing-library#1466 · 2 commentaires ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 30/100
testing-library/react-testing-library#1459 · 2 commentaires ·
-
perf: optimize container lookup with early exitPeut-être à nouveau libre @Ch-Abhinav-Chowdary l’a pris il y a 322 jours, et aucune pull request n’est ouverte. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 35/100
testing-library/react-testing-library#1430 · 1 commentaire ·
-
`fireEvent.mouseEnter` does not forward `relatedTarget` (relatedTarget is the window instead)Peut-être pris @swarnim02 l’a pris il y a 339 jours. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
Toutes les issues de testing-library/react-testing-library
Issues similaires
-
Site Suggestion: bullseyeOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 65/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
Les mainteneurs répondent en général sous 25 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
libnativeapi/nativeapi#21 ·
-
area: core complexity: easy impact: medium
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
ueberdosis/tiptap#8668 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour