我有这个简单的测试
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
有什么想法吗?