Flaky React tests with MockedProvider

Good day,

Does anyone else have issues around test flakiness when using MockedProvider with React?

The documentation suggests something like

await new Promise(resolve => setTimeout(resolve, 0));

As a means of waiting for the next tick presumably so that things like useQuery have the time to complete. This is not ideal because in some cases it won’t be ready. There are also scenarios where you basically have to wait “twice” or more in a row, etc. which is just awkward.

When the tests run under CI it sometimes results in false negatives, etc, which is a drag to deal with.

While on the subject, sometimes the mocked provider will not return any data when interfaces are used if __typename isn’t provided, etc. but silently fails instead of perhaps detecting the issue and warning the user. This could be made more clear in the documentation.

Could MockedProvider be improved with a more reliable way to handle the asynchronous nature of the code in a testing environment?