import { act } from './ReactTestingLibrary'; /** * Wrapper around `act`. * * Awaits an `act` call, * and returns the value of the state update callback */ export const waitForState = async ( callback: () => T, ): Promise => { let val: T; await act(() => { val = callback(); }); // @ts-expect-error - val is returned before TS sees it as being defined return val; };