title: jest.spyOn() on factory function of jest.mock("path", factory function)
body: <p>I am trying to spyOn a mocked factory function named getObject.
  I am doing it like this:</p>
  
  <pre><code>import Storage from "/path/"
  const fs1 = new Storage("ffffff");
  const fs = mocked(fs1);
  
  jest.mock("path to library", () =&gt; {
    return {
      CAStorage: function () {
        return {
          getObject: async (
            _baseDirName: string,
            _fileName?: string
          ): Promise&lt;Buffer&gt; =&gt; {
            return Buffer.from(
              `some string`
            );
          },
        };
      },
    };
  });
  </code></pre>
  
  <p>the spyOn code</p>
  
  <pre><code>describe("", () =&gt; {
    test("", async () =&gt; {
      let readFileSpy = jest.spyOn(fs, "getObject");
      expect(readFileSpy).toBeCalledTimes(1);
    });
  });
  </code></pre>
  
  <p>The error I am getting is:
  Expected number of calls: 1
  Received number of calls: 0</p>
  
  <p>even though the function have been called once.</p>
  
  <p>Thanks for the help!</p>