title: Jest mock function inside function
body: <p>I have no idea how to mock return value of inner function inside jest
  I tried different approaches. Finally I found this <a href="https://stackoverflow.com/questions/51269431/jest-mock-inner-function">answer</a>
  but value not mocking for some reason, here it is example:</p>
  
  <p>countries.js</p>
  
  <pre class="lang-js prettyprint-override"><code>export const countryList = () =&gt; [
        {
          label: '+244',
          value: 'Angola',
        }, // list of all possible countries very long...
   ];
  
  export const getSortedCountryData = intlLang =&gt;
    countriesList()
    .sort((compare, comparable) =&gt;
      compare.value.localeCompare(comparable.value, intlLang, { sensitivity: 'base' }));
  </code></pre>
  
  <p>countries.test.js</p>
  
  <pre class="lang-js prettyprint-override"><code>import * as countyListHelper from './countries';
  
  describe('countries list', () =&gt; {
    test('returns list of countries', () =&gt; {
      const mockFn = jest.mock();
  
      const expectedList = [
        {
          label: '+244',
          value: 'Angola',
        },
        {
          label: '+43',
          value: 'Austria',
        },
      ];
  
      mockFn.spyOn(countyListHelper, 'countriesList').mockReturnValue(expectedList);
  
      // console.log('if return value mocked correctly',
      // countyListHelper.countriesList() === expectedList); // true
      expect(countyListHelper.getSortedCountryData('en')).toEqual(expectedList);
      // shows error with received value list of all countries instead of mocked one
    });
  });
  </code></pre>
  
  <p>Please suggest me any possible solutions why inside test function mocked return value for inner function is ignored. Setup from Create React App.</p>