from the official docs https://testing-library.com/docs/dom-testing-library/api-async/ which uses:
await waitFor(() => expect(mockAPI).toHaveBeenCalledTimes(1))
but what if my codebase does have a bug which causes the api (mocked by mockAPI
) not being called, then how does the above statement can do unit test properly because after the default timeout (1000ms), waitFor
won't call the callback again, so the expect
is not being called to throw an error, then the bug is swallowed, unless waitFor
is designed to call one more time after the timeout? but I didn't find the official docs mention it?