Slow getByRole leads to test timeouts
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Bug
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- javascript, react
- Bereich
- performance, testing-qa
Rechercherichtung
Beginne mit der verknüpften Testing Playground-Reproduktion und dem genannten getByRole-Einstiegspunkt und profiliere anschließend die wiederholten Aufrufe mit dem bereitgestellten Ant Design-artigen Rendern. Vergleiche die aktuelle Ausführungszeit mit den gemeldeten ungefähr 1,6 Sekunden pro Aufruf; abgeschlossen ist die Aufgabe, wenn die Reproduktion keine Test-Timeouts mehr verursacht, ohne das beabsichtigte Verhalten des Tests zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
@testing-library/reactversion: 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.
Problem description:
getByRole() takes a lot of time in this jest test. I used the profiler to get a feeling, on how long.
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
- Vorherrschende Sprache
- JavaScript
- Sterne
- 19.7k
- Forks
- 1.2k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus testing-library/react-testing-library
-
fireEvent.select does not wrap its automatic native focus in actEvtl. vergeben @sergioperezcheco hat das vor 19 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
bug: calling configure() without reactStrictMode resets it to undefined, silently disabling strict modeEvtl. wieder frei @suhailopensource hat das vor 89 Tagen übernommen, und es ist kein Pull Request offen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 35/100
testing-library/react-testing-library#1466 · 1 Kommentar ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 30/100
testing-library/react-testing-library#1459 · 2 Kommentare ·
-
perf: optimize container lookup with early exitEvtl. wieder frei @Ch-Abhinav-Chowdary hat das vor 315 Tagen übernommen, und es ist kein Pull Request offen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 35/100
testing-library/react-testing-library#1430 · 1 Kommentar ·
-
`fireEvent.mouseEnter` does not forward `relatedTarget` (relatedTarget is the window instead)Evtl. vergeben @swarnim02 hat das vor 333 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
Alle Issues in testing-library/react-testing-library
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement good first issue help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
yunaremaia/jsonl-cli#1 · 1 Kommentar ·
-
agent-ready agent:in-progress backend/api
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 3 Tagen
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug needs-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
apex-dev-tools/apex-log-parser#199 ·
Maintainer antworten meist innerhalb von 1 Tag