Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

345
Visualizações
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 Respostas
Responde à pergunta

0

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

about 4 years ago · Juan Pablo Isaza Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda