You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After-paint actions scheduled with useEffect are currently scheduled to execute using requestAnimationFrame followed by a setTimeout(callback, 0) by default. It isn't very obvious how to:
Make any pending effects execute and update the Enzyme wrapper to reflect the final rendered state
Clean up properly at the end of a test
From what I gather, this is the not-very-clearly explained purpose of act() (React docs).
I think what we'll want to do here is:
Wrap the initial render in act() so that all effects have executed by the time the developer starts interacting with the returned wrapper
Wrapper event dispatches and other updates through the wrapper in act for the same reason
Make sure there is documentation in place about what to do for manipulations of components that happen outside of the wrapper (timeouts, events manually dispatched to DOM elements etc.)
Try to figure out how to simplify cleanup at the end of a test
I also wonder whether the adapter should automatically register a replacement for options.requestAnimationFrame, since we want tests to execute as fast as possible.
The text was updated successfully, but these errors were encountered:
Another thing we could do would be to make the {MountRenderer, ShallowRenderer}#getNode methods flush any pending effects and renders before returning the node. This would at least provide a predictable way (wrapper.update()) of ensuring that everything was up to date before querying the wrapper. I need to check if this is consistent with how the React adapters work.
After-paint actions scheduled with
useEffect
are currently scheduled to execute usingrequestAnimationFrame
followed by asetTimeout(callback, 0)
by default. It isn't very obvious how to:From what I gather, this is the not-very-clearly explained purpose of act() (React docs).
I think what we'll want to do here is:
act()
so that all effects have executed by the time the developer starts interacting with the returned wrapperact
for the same reasonI also wonder whether the adapter should automatically register a replacement for
options.requestAnimationFrame
, since we want tests to execute as fast as possible.The text was updated successfully, but these errors were encountered: