77
rated 0 times
[
82]
[
5]
/ answers: 1 / hits: 16772
/ 5 Years ago, tue, september 17, 2019, 12:00:00
Using react and react-dom 16.9.0
I am getting this warning when I'm testing my react hooks:
console.error node_modules/react-dom/cjs/react-dom-test-utils.development.js:80
Warning: Do not await the result of calling act(...) with sync logic, it is not a Promise.
My test code (using jest with @testing-library/react)
...
await act( () => {
rerender(
<HookTester
promise={asyncFunction}
initialValue={'extra loading...'}
/>
);
});
expect(asyncFunction).toHaveBeenCalledTimes(2);
...
But if I don't await, then my expect
ation would be done too early.
More From » reactjs