为什么我的应用程序中未定义地址?

Why is address undefined in my app?

我有一个简单的快递应用程序:

var express = require('express');
var path = require('path');

var app = express();
exports.app = app;

var index = require('./routes/index');

app.use(express.static(path.join(__dirname,'client/dist/')));

app.get('/', index.get);

function start(){
    var port = process.env.PORT || 8080;

    app.listen(port, function(){
        console.log('app is running on port: ' + port);
    });
};

exports.start = start;

以及集成测试:

var request = require('supertest');

var app = require('../app');

describe('GET /', function(){
    it('should repsond with 200', function(done){
        request(app)
        .get('/')
        .expect(200, done.fail);
    });
});

应用程序运行正常,但是 运行 集成测试,出现以下错误:

Failures: 
1) GET / should repsond with 200
1.1) TypeError: Object #<Object> has no method 'address'

我进行了一些搜索,似乎应用程序未正确导出,但我似乎无法弄清楚原因。

request(app.app) 而不是集成测试中的 request(app) 应该可以修复错误。

var request = require('supertest');
var app = require('../app');

describe('GET /', function(){
  it('should repsond with 200', function(done){
      request(app.app)
      .get('/')
      .expect(200, done.fail);
  });
});