title: how to refer to a function when unit testing with NodeJS / Mocha
body: <p>I'm making my first test with Mocha.</p>
  
  <p>Dummy test is passing, but when I want to refer to my actual function that is in another file, it won't find it:</p>
  
  <pre><code>ReferenceError: main is not defined
  </code></pre>
  
  <p>I have a single index.js with :</p>
  
  <pre><code>async function main() {
      function comparer(otherArray) {
          return function (current) {
              return otherArray.filter(function (other) {
                  return other.prm === current.prm &amp;&amp; other.conso_prod === current.conso_prod
              }).length === 0;
          }
      }
  }
  
  module.exports = main();
  </code></pre>
  
  <p>and in my test.js file, I do:</p>
  
  <pre><code>const {expect} = require('chai');
  
  describe('Sum numbers', () =&gt; {
      it('Compare 2 existing array', () =&gt; {
          const meters = []
          const perimeter = []
          const onlyInMeters = meters.filter(main.comparer(perimeter));
          expect(onlyInMeters).to.equal([]);
      });
  });
  </code></pre>
  
  <p>But when I refer to <code>main.comparer</code>, it can't find it:</p>
  
  <pre><code>ReferenceError: main is not defined
  </code></pre>
  
  <p>What am I forgetting? Sorry, I'm a NodeJS Noob!</p>