post-upgrade, unexpected assertion failures on error-handling function calls (includes repro)
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Bug
- Clareza
- Precisa de esclarecimento
- Status de atividade
- Estagnada
- Stack de tecnologia
- javascript, react
Direção de pesquisa
Comece pela reprodução de CRA vinculada e inspecione a sequência de asserções de render, findByText e mockLog mostrada na issue. Confirme o comportamento de timing após a atualização e documente por que esperar pelo erro renderizado não estabelece que a chamada de logging baseada em effect foi concluída.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
@testing-library/reactversion: 13.4.0- Testing Framework and version: [email protected]
- DOM Environment: [email protected]
- node: 16.14.2
- react: 18.2.0
Relevant code or config:
render(<App />);
await screen.findByText('Failed!');
//assertion fails unless we `waitFor` it
expect(mockLog).toHaveBeenCalledWith('kaboom!')
What you did:
Upgraded existing application to react 18+ and RTL 13+.
What happened:
A number of tests starting failing assertions after upgrading.
In this case, the component is rendered with a simulated fetch failure. The component renders a child component that is responsible for error presentation and minor logging (in an effect hook). The test assertion on the logging function call fails unless it is awaited.
Reproduction:
I was able to reproduce the issue with a simple CRA repo, here: https://github.com/trv-wcaneira/fetch-err-waitfor-mcve
Problem description:
Pre-upgrade, it was sufficient to await the error message text rendered by the child component. Now it seems additional waiting is needed, and before I plaster waitFors all over our tests 😄, I'd just like to understand why.
Suggested solution:
I could obviously change all the tests to waitFor the logging function call, but would like to understand the change in behavior.
- 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á 9 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 livre de novo @suhailopensource assumiu há 79 dias e não há nenhum pull request aberto. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 35/100
testing-library/react-testing-library#1466 · 1 comentário ·
-
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á 305 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á 323 dias. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 55/100
Todas as issues de testing-library/react-testing-library
Issues semelhantes
-
[Website] Catalog: unknown sort value and mixed-case technology in the URL break the filtersTalvez já em andamento @barbierajput378-pixel assumiu hoje. Abertaarea/website framework/jekyll help wanted language/css language/javascript language/markdown
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 80/100
meshery/meshery.io#3088 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
firecrawl/firecrawl-mcp-server#548 ·
Mantenedores costumam responder em até 1 dia
-
Area:WebGL p5.js 2.0+
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
processing/p5.js#9302 ·
Mantenedores costumam responder em até 3 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
documentation good first issue hacktoberfest
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
wassim-azi/agy-powerline#47 ·
Mantenedores costumam responder em até 1 dia