Closed sibelius closed 3 years ago
This would completely change the usage of jest-fetch-mock and not something we're interested in doing.
This error message is more about how you write your tests than how Jest fetch mock operates. If you post a simple example we might be able to offer more assistance but we're not interested in changing the library as you've asked.
I fixed this using this code
await act(async () => {
await new Promise((resolve) => setImmediate(resolve));
});
it will flush all promises and react hooks
https://kentcdodds.com/blog/fix-the-not-wrapped-in-act-warning
We can get this warning when using jest-fetch-mock and React components
as jest-fetch-mock will update the React component outside React itself
we probably need to wrap the promise resolved by jest-fetch-mock inside act like this
the problem is that
fetchMock.mockResponseOnce
does not return the promise that will be resolvedthis API could help us