title: SuperTest - App is not defined
body: <p>I'm new to test driven development and am trying to use supertest to teach myself. I'm confused as to why I keep getting the error "app is not defined"? It is from my calls to request(app) which I have bolded below.  I tried to look up the documentation but there doesn't seem to be much.  All of my routes are in a file called "middleware", and that file starts like this:</p>
  
  <pre><code> var bodyParser = require('body-parser');
      var helpers = require('./helpers.js'); // our custom middleware
      var db = require('../DB/DB.js');
      var router = require('../routes.js');
      var path = require('path');
      var fs = require('fs');
      var gm = require('gm');
  
  
      module.exports = function (app, express) {}
  </code></pre>
  
  <hr>
  
  <p>The actual file where I use supertest to test the middleware file's routes:</p>
  
  <pre><code>    var chai = require('chai')
      var assert = chai.assert;
      var should = chai.should();
      var expect = chai.expect;
      var helpers = require("../config/helpers.js");
      var middleware = require("../config/middleware.js");
      // for when we eventually want to test against mock data
      var fs = require('fs');
      var path = require('path');
      var supertest = require("supertest")(middleware);
  
  describe('middleware API', function() {
  
  
    it('responds with binary data', function(done) {
      var imagePath = path.join(__dirname, '/../assets/drawings/', userName + '.png');
      **request(app)**
        .get(imagePath)
        .expect(201)
        .expect('Content-Type', 'image.png')
        .parse(binaryParser)
        .end(function(err, res) {
          if (err) return done(err);
  
          // binary response data is in res.body as a buffer
          assert.ok(Buffer.isBuffer(res.body));
          console.log("res=", res.body);
  
          done();
        });
    });
  
    it('sends back one image', function(done) {
      **request(app)**
        .get('/game/')
        .expect(201)
        .expect('Content-Type', 'image.png')
        .expect('Content-Length', '1')
        .parse(binaryParser)
        .end(function(err, res) {
          if (err) return done(err);
  
          // binary response data is in res.body as a buffer
          assert.ok(Buffer.isBuffer(res.body));
          console.log("res=", res.body);
  
          done();
        })
  
    })
  })
  </code></pre>