Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

349
Vistas
React Native Testing Library shows a warning for using `waitFor`

I have this test with Jest and react-native-testing-library

it('submits form on submit button press', async () => {
  const onSubmit = jest.fn();
  const values = { username: 'jack' };
  const { getByRole } = render(
    <Form initialValues={values} onSubmit={onSubmit} />,
  );

  const button = getByRole('button');

  fireEvent.press(button);

  await waitFor(() => {
    expect(onSubmit).toBeCalledWith(values, expect.anything());
  });
});

It passes, but it throws this warning

Warning: You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one.

NOTE: if I remove waitFor the warning goes aways but the test fails because it doesn't call the onSubmit function immediatly.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Changing Jest preset from "react-native" to "@testing-library/react-native" solved the problem.

about 4 years ago · Juan Pablo Isaza Denunciar

0

try to change

await waitFor(() => {
    expect(onSubmit).toBeCalledWith(values, expect.anything());
});

to

waitFor(() => {
    expect(onSubmit).toBeCalledWith(values, expect.anything());
});
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda