title: How to test in react today.getFullYear() + 1
body: <p>I want to test following line of code in React:</p>
  <pre><code>const today = new Date()
  export const nextYear = today.getFullYear() + 1
  </code></pre>
  <p>What I've tried:</p>
  <pre><code>import { nextYear } from '../nextYear'
  import MockDate from 'mockdate'
  
  describe('NextYearHelper', () =&gt; {
    describe('nextYear', () =&gt; {
      it('returns next year', () =&gt; {
        MockDate.set('2030-11-22')
        expect(nextYear).toEqual(2031)
      })
    })
  })
  </code></pre>
  <p>I can see the mock date in the example calling <code>new Date()</code> but test does not pass. I also tried:</p>
  <pre><code>export const nextYear = () =&gt; today.getFullYear() + 1
  </code></pre>
  <p>And try to see if <code>new Date()</code> returns the mock value, but without success.</p>
  <ol>
  <li>Why the <code>new Date()</code> call is not being mocked in the code and it is in the example?</li>
  <li>Even for a small computation like this one, should it be a function instead of a constant?</li>
  </ol>