title: How to mock/spy useState hook in jest?
body: <p>I am trying to spy on useState React hook but i always get the test failed</p>
  <p>This is my React component:</p>
  <pre><code>const Counter= () =&gt; {
      const[counter, setCounter] = useState(0);
  
      const handleClick=() =&gt; {
          setCounter(counter + 1);
      }
  
      return (
          &lt;div&gt;
              &lt;h2&gt;{counter}&lt;/h2&gt;
              &lt;button onClick={handleClick} id=&quot;button&quot;&gt;increment&lt;/button&gt;
          &lt;/div&gt;
      )
  }
  </code></pre>
  <p><strong>counter.test.js</strong>:</p>
  <pre><code>it('increment counter correctlry', () =&gt; {
      let wrapper = shallow(&lt;Counter/&gt;);
      const setState = jest.fn();
      const useStateSpy = jest.spyOn(React, 'useState');
  
      useStateSpy.mockImplementation((init) =&gt; [init, setState]);
       const button = wrapper.find(&quot;button&quot;)
       button.simulate('click');
       expect(setState).toHaveBeenCalledWith(1);
  })
  </code></pre>
  <p>Unfortunately this doesn't work and i get the test failed with that message:</p>
  <pre><code>expected 1
  Number of calls: 0
  </code></pre>