title: How to test React useEffect hooks with jasmine and enzyme
body: <p>I can't find how to call my useEffect hooks while testing my component.</p>
  
  <p>I tried several solution like this one, but it didn't work: <a href="https://reactjs.org/docs/test-utils.html#act" rel="nofollow noreferrer">https://reactjs.org/docs/test-utils.html#act</a></p>
  
  <p>My component :</p>
  
  <pre><code>const mapDispatchToProps = (dispatch: IDispatch, ownProps: ITextAreaOwnProps): ITextAreaDispatchProps =&gt; ({
          onMount: () =&gt; dispatch(addTextArea(ownProps.id)),
  });
  
  export const TextArea = (props) =&gt; {
          React.useEffect(() =&gt; {
              props.onMount();
          }, []);
  
          // more code... //
  
          return (
              &lt;&gt;
                  &lt;TextareaTagName
                      {...props.additionalAttributes}
                      className={props.className}
                  /&gt;
                  {props.children}
                  {getValidationLabel()}
              &lt;/&gt;
          );
      };
  </code></pre>
  
  <p>My test :</p>
  
  <pre><code>it('should call prop onMount on mount', () =&gt; {
      const onMount = jasmine.createSpy('onMount');
  
      mount(&lt;TextArea id="textarea-id" onMount={onMount} /&gt;);
  
      expect(onMount).toHaveBeenCalledTimes(1);
  });
  </code></pre>