title: How do I test a jest console.log
body: <p>I'm using <strong>create-react-app</strong> and trying to write a <strong>jest</strong> test that checks the output of a <code>console.log</code>.</p>
  <p>My function to test is:</p>
  <pre><code>export const log = logMsg =&gt; console.log(logMsg);
  </code></pre>
  <p>My test is :</p>
  <pre><code>it('console.log the text &quot;hello&quot;', () =&gt; {
    console.log = jest.fn('hello');
    expect(logMsg).toBe('hello');
  });
  </code></pre>
  <p>Here is my error</p>
  <pre><code> FAIL  src/utils/general.test.js
    ● console.log the text hello
  
      expect(received).toBe(expected)    Expected value to be (using ===):      &quot;hello&quot;
      Received:
        undefined
      Difference:
        Comparing two different types of values. Expected string but received undefined.
  </code></pre>