title: Mock function A called within B when A is defined within the same file
body: <p>I have a file (<code>example.js</code>) that looks like this and I'd like to test it. </p>
  
  <pre><code>function alpha () {
    return 'alpha'
  }
  
  function beta () {
    return alpha() + ' ' + 'beta'
  }
  </code></pre>
  
  <p>Here's an example of the test for that file:</p>
  
  <pre><code>const test = require('ava')
  const {beta} = require('./example')
  
  test(t =&gt; {
    t.is(beta(), 'alpha beta')
  })
  </code></pre>
  
  <p>I'm interested in having mocking the use of <code>alpha</code> within <code>beta</code>, when <code>beta</code> is defined within <code>example.js</code>. I know things that mock the <code>require</code> call so that dependencies could be mocked, but that's not what I'm looking for. </p>