import { fireEvent, waitFor } from '@testing-library/react'; import { act } from '../ReactTestingLibrary'; /** * Fires the `transitionEnd` event on the provided element, * triggering any event handlers attached to this CSS transition events. * * Ensures `onEntered`, `onExited` handlers are fired when * using `react-transition-group` */ export async function waitForTransition( element?: HTMLElement | Parameters[0] | null, options?: Parameters[1], ) { if (element) { await waitFor(() => { act(() => { fireEvent.transitionEnd(element, options); }); }); } }