I have this function and i am trying to test it here:
I am trying to make the onClose function callable, but I get an error at this line => expect(onClose).toHaveBeenCalled();
>Solution :
Since your onClose function is not called directly but asyncronously, after some other action you should use the react testing library async API waitFor method which depicts that you expect something to eventually happen.
Your expectation should look like this
await waitFor(() => expect(onClose).toHaveBeenCalled());
Also don’t forget to wrap your testing block with async in order to be able to use await.

