title: How to mock returned value from a react hook in Jest unit test
body: <p>I have a custom hook <code>useAuth0</code>. I need to mock a specific function (<code>logout</code>) returned by the hook and keep the real funcionality of the rest. Is there a solution for this case?</p>
  <p>I tried:</p>
  <pre class="lang-js prettyprint-override"><code>jest.spyOn(useAuth0(), 'logout') // invalid hook call
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>jest.mock('lib/hooks/useAuth0', () =&gt; () =&gt; ({
    ...jest.requireActual('lib/hooks/useAuth0'),
    logout: jest.fn()
  })) // mocking the module instead of the returned value
  
  expect(useAuth0().logout).toHaveBeenCalled() // fails - logout not called
  </code></pre>