TypeError:无法读取未定义超类的属性“地址”

我需要一些帮助来解决testingnodejs代码的问题。 我正在使用摩卡和超级特技。 我很困惑与supertest的实施。 我不知道要解决这个问题。 我试图自动下载一个文件。

`describe('GET /entry/:entryId/file/:id/download', function(){ it('should pass download function', function(done){ this.timeout(15000); request(app.webServer) .get('/entry/543CGsdadtrE/file/wDRDasdDASAS/download') .set('Authorization', 'Bearer eyJ0eXAiOiJKV1QiLCJhbGco') .expect(200) .end(function(err, res){ if (err) return done(err); console.log(err, res); done(); }); }); }); 

testing快速应用程序时,我收到了摩卡的类似错误。 错误全文:

 0 passing (185ms) 2 failing 1) loading express responds to /: TypeError: app.address is not a function at Test.serverAddress (test.js:55:18) at new Test (test.js:36:12) at Object.obj.(anonymous function) [as get] (index.js:25:14) at Context.testSlash (test.js:12:14) 2) loading express 404 everything else: TypeError: app.address is not a function at Test.serverAddress (test.js:55:18) at new Test (test.js:36:12) at Object.obj.(anonymous function) [as get] (index.js:25:14) at Context.testPath (test.js:17:14) 

我通过将其添加到我的express server.js,即导出服务器对象来解决它

 module.exports = app 

正在面对这个错误的Typescript用户检查两件事情:

  1. 快递服务器应该有module.exports = app (感谢@Collin D )
  2. 使用import * as app from "./app"
    而不是import app from "./app" 错误的 import app from "./app"