import TestRenderer from "react-test-renderer" ; import { isPromiseLike } from "coral-common/utils" ; export default function act < T > ( callback ) { let callbackResult ; const actResult = TestRenderer . act ( ( ) => { callbackResult = callback ( ) ; if ( isPromiseLike ( callbackResult ! ) ) { return callbackResult as any ; } return ; } ) ; if ( isPromiseLike ( callbackResult ! ) ) { return { then ( resolve , reject ) { ( actResult as PromiseLike < any > ) . then ( ( ) => { resolve ( callbackResult ) ; } , reject ) ; } , } as any ; } return callbackResult ! ; }