Jest mocking reference error : <p>I'm trying to use the following mock:</p>

<pre><code>const mockLogger = jest.fn();

jest.mock("./myLoggerFactory", () =&gt; (type) =&gt; mockLogger);
</code></pre>

<p>but mockLogger throws a reference error.</p>

<p>I know jest is trying to protect me from reaching outside of the scope of the mock, but I need a reference to <code>jest.fn()</code> so I can assert that it was called correctly.</p>

<p>I'm only mocking this because I'm doing an outside-in acceptance test of a library. Otherwise I would thread the reference to the logger all the way through as a parameter rather than mocking.</p>

<p>How can I achieve this?</p>
