title: Mocha how to expose a node controller function to test script
body: <p>Here is my <code>foo-controller.js</code>.</p>
  
  <pre><code>module.exports = function(params) {
  
      var router = require('express').Router();
      var db = params.db
      var controller = {};
  
      controller.getFoo = function (req, res) {
          // returns something
      }
  
      router.get('/foo', controller.getFoo);
  
      return router;
  
  };
  </code></pre>
  
  <p>and here is my <code>test.js</code>.</p>
  
  <pre><code>var chai = require('chai');
  var expect = require('chai').expect;
  var bar = require('../api/controllers/bar/foo-controller');
  
  console.log("Test", bar) // &lt;- this returns the whole foo-controlelr.js
  
  describe('Foo', function() {
      it('should blah blah', function() {
  
      });
  });
  </code></pre>
  
  <p>But every time I to use <code>bar.getFoo()</code> &lt;- the function I wanted to test. It returns the error <code>has no method 'getFoo'</code></p>