Slow getByRole leads to test timeouts
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 25/100
- Tipo de issue
- Bug
- Clareza
- Precisa de esclarecimento
- Status de atividade
- Estagnada
- Stack de tecnologia
- javascript, react
- Domínio
- performance, testing-qa
Direção de pesquisa
Comece com a reprodução vinculada do Testing Playground e o ponto de entrada getByRole mencionado; em seguida, faça o profiling das chamadas repetidas usando o render fornecido no estilo do Ant Design. Compare o tempo de execução atual com os aproximadamente 1,6 segundos por chamada relatados; considera-se concluído quando a reprodução não causar mais timeouts nos testes sem alterar o comportamento pretendido do teste.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
@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
- Linguagem predominante
- JavaScript
- Estrelas
- 19.7k
- Forks
- 1.2k
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de testing-library/react-testing-library
-
fireEvent.select does not wrap its automatic native focus in actTalvez já em andamento @sergioperezcheco assumiu há 28 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
-
bug: calling configure() without reactStrictMode resets it to undefined, silently disabling strict modeTalvez já em andamento @nimbly1 assumiu há 9 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 35/100
testing-library/react-testing-library#1466 · 2 comentários ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 30/100
testing-library/react-testing-library#1459 · 2 comentários ·
-
perf: optimize container lookup with early exitTalvez livre de novo @Ch-Abhinav-Chowdary assumiu há 324 dias e não há nenhum pull request aberto. Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 35/100
testing-library/react-testing-library#1430 · 1 comentário ·
-
`fireEvent.mouseEnter` does not forward `relatedTarget` (relatedTarget is the window instead)Talvez já em andamento @swarnim02 assumiu há 342 dias. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 55/100
Todas as issues de testing-library/react-testing-library
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
-
area:docs good first issue help wanted priority:medium type:chore
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
mahmutmft/courses-mcp#51 ·
Mantenedores costumam responder em até 1 dia
-
good first issue roadmap ux
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
AhmedNavaz/throughline#100 ·
-
good first issue
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 90/100
samiromer2/Ruby-Consent-Portal#26 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 79/100
django-helpdesk/django-helpdesk#1496 · 1 comentário ·
Mantenedores costumam responder em até 1 dia