title: Jest onSpy - expected mock function to have been called
body: <p>I'm struggling with using spyOn as part of testing my utils.js module. I've tried various methods and approaches but all seem to yield the "expected mock function to have been called". For the record, other unit tests work OK, so there shouldn't be any issue with my actual test setup.</p>
  
  <p>Below is a simplified test case with two functions and one test, and I can't even get these to work. Did I misunderstand the spyOn altogether?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// utils.js
  function capitalHelper(string){
    return string.toUpperCase();
  }
  
  function getCapitalName(inputString){
    return capitalHelper(inputString.charAt(0)) + inputString.slice(1);
  }
  
  exports.capitalHelper = capitalHelper
  exports.getCapitalName = getCapitalName
  
  
  
  // utils.test.js
  const Utils = require('./utils');
  
  test('helper function was called', () =&gt; {
    const capitalHelperSpy = jest.spyOn(Utils, 'capitalHelper');
    const newString = Utils.getCapitalName('john');
    expect(Utils.capitalHelper).toHaveBeenCalled();
  })</code></pre>
  </div>
  </div>
  </p>