Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

post-upgrade, unexpected assertion failures on error-handling function calls (includes repro)

Abierto
#1,127 5 comentarios 8 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
javascript, react
Área
frontend, testing

Línea de trabajo

Comienza con la reproducción de CRA enlazada e inspecciona la secuencia de aserciones de render, findByText y mockLog que se muestra en el issue. Confirma el comportamiento temporal posterior a la actualización y documenta por qué esperar al error renderizado no demuestra que la llamada de logging basada en un efecto haya terminado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
JavaScript
Estrellas
19.7k
Forks
1.2k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de testing-library/react-testing-library

Todos los issues de testing-library/react-testing-library

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.