title: Mocha returns undefined for prototype method
body: <p>I'm trying to run some Mocha tests against a Node module that uses the prototype pattern for creating objects. The code itself runs just fine, but the tests don't.</p>
  
  <p>Here's the code I'm trying to test:</p>
  
  <pre><code>"use strict";
  
  const fs = require("fs"),
    request = require("request"),
    EventEmitter = require("events").EventEmitter,
    util = require("util");
  
  const FileController = function(url, path) {
    EventEmitter.call(this);
  
    this.url = url;
    this.path = path;
  };
  
  FileController.prototype.downloadFile = function() {
    if (this.url) {
      let file = fs.createWriteStream(this.path);
  
      file.on("finish", function() {
        file.close(function() {
          this.emit("downloaded");
        });
      }).on("error", function(err) {
        this.handleDownloadError(err, "file-error");
      });
  
      // Download the file.
      request.get(this.url)
        .on("response", function(res) {
          if (res.statusCode == 200) {
            res.pipe(file);
          } else {
            fs.unlink(this.path);
          }
  
          this.emit("stream", res);
        })
      .on("error", function(err) {
        this.handleDownloadError(err, "request-error");
      });
    }
  };
  
  FileController.prototype.handleDownloadError = function(err, type) {
    fs.unlink(this.path);
    this.emit(type, err);
  };
  
  util.inherits(FileController, EventEmitter);
  
  module.exports = FileController;
  </code></pre>
  
  <p>And then here's the relevant parts of my test code where I instantiate an object:</p>
  
  <pre><code>beforeEach(function() {
    let url = "http://example.com/logo.png",
      path = config.downloadPath + "/cdf42c077fe6037681ae3c003550c2c5";
  
    fileController = new FileController(url, path);
    // Outputs 'undefined'.
    console.log(fileController.downloadFile);
  });
  </code></pre>
  
  <p>When I make the call to <code>new FileController(url, path)</code>, it is not attaching the <code>downloadFile</code> method that I've attached to the prototype. Instead, trying to call that function gives me <code>fileController.downloadFile is not a function</code>.</p>
  
  <p>Any thoughts as to where the problem lies?</p>
  
  <p>Thx!</p>