act function
A test helper to apply pending React updates before making assertions.
This is RTL's version of React.act for convenience because it handles setting IS_REACT_ACT_ENVIRONMENT
to avoid https://react.dev/reference/react/act#error-the-current-testing-environment-is-not-configured-to-support-act.
See RTL docs: https://testing-library.com/docs/react-testing-library/api/#act See React docs: https://react.dev/reference/react/act
Implementation
Future<void> act(FutureOr<void> Function() callback) async {
final callbackReturnValue = callback();
final jsCallback =
([_, __, ___]) => callbackReturnValue is Future ? futureToPromise(callbackReturnValue) : callbackReturnValue;
final promise = _act(allowInterop(jsCallback)) as Object;
await promiseToFuture<void>(promise);
}