let mockUnmountHandler ; export const unmountHandler = ( ) => mockUnmountHandler ( ) ; jest . mock ( 'react' , ( ) => ( { ... ( jest . requireActual ( 'react' ) as object ) , useEffect : jest . fn ( ( fn ) => { mockUnmountHandler = fn ( ) ; return mockUnmountHandler ; } ) , } ) ) ; /**
 * Example usage within a component test using shallow():
 *
 * import '../../../__mocks__/shallow_useeffect.mock'; // Must come before React's import, adjust relative path as needed
 *
 * import React from 'react';
 * import { shallow } from 'enzyme';
 *
 * // ... etc.
 */ /**
 * Example unmount() usage:
 *
 * import { unmountHandler } from '../../../__mocks__/shallow_useeffect.mock';
 *
 * it('unmounts', () => {
 *   shallow(SomeComponent);
 *   unmountHandler();
 *   // expect something to have been done on unmount (NOTE: the component is not actually unmounted)
 * });
 */