title: Test case for node js with sinon and chai
body: <p>I am trying to use sinon to do a unit test for one of my node functions.</p>
  
  <p>Below is the actual function.</p>
  
  <pre class="lang-js prettyprint-override"><code>import { replaceYears, getFinancialYears } from './utils/years/';
  
  const replaceAssetFileName = () =&gt; {
    const years = getFinancialYears(); // return array of years [2019, 2018, 2017]
    for (let i = 0; i &lt; years.length; i++) {
      replaceYears(years[i], 'NEWNAME'); // replace years just replace 2019 to FY19, don't ask why a function is written for this.
    }
    return true;
  };
  </code></pre>
  
  <p>I want to mock the function <code>getFinancialYears</code>, so that just for test the function can return only one or two years instead of 100s of years.</p>
  
  <p>I tried below test case with sinon and chai. But still I see the function  “getFinancialYears” giving out the actually list of years instead of fakes.</p>
  
  <pre class="lang-js prettyprint-override"><code>it('We can replace file names', () =&gt; {
    const stub = sinon.stub(util, 'getFinancialYears').callsFake(() =&gt; ['2019']);
    expect(replaceAssetFileName()).to.be(true);
    stub.restore();
  }).timeout(20000);
  </code></pre>