May 2019
Intermediate to advanced
496 pages
10h 38m
English
So far, our submit button causes a fetch request to be made, but it doesn't do anything with the response. In particular, it doesn't wait for the response; the fetch API is asynchronous and returns a promise. Once that promise resolves, we can do something with the data that's returned.
The next tests we'll write will specify what our component should do with the resolved data.
In order to write these tests, we'll need to use a React function named act. We're required to use this function when our actions perform any kind of side-effects that happen outside the synchronous flow of our components, including resolving promises.
There are two forms of act: a synchronous form and an asynchronous form. We'll be using ...
Read now
Unlock full access