摩卡/超级测试中未定义的地址

时间:2019-02-21 18:07:53

标签: node.js express mocha chai supertest

我有这个简单的测试

describe('Returns json', function() {
  it('all bookings', function(done) {
    request(app)
      .get('/route')
      .set('Accept', 'application/json')
      .expect('Content-Type', /json/)
      .expect(200, done);
  });
});

运行mocha时出现以下错误

TypeError: Cannot read property 'address' of undefined
      at Test.serverAddress (node_modules/supertest/lib/test.js:55:18)
      at new Test (node_modules/supertest/lib/test.js:36:12)
      at Object.obj.(anonymous function) [as get] (node_modules/supertest/index.js:25:14)
      at Context.<anonymous> (test/test.js:22:8)

我尝试了其他用户的建议,特别是these answers

有什么想法吗?

0 个答案:

没有答案