Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

343
Views
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 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!