Ensuring Express App is running before each Mocha Test

后端 未结 6 2093
别跟我提以往
别跟我提以往 2020-12-13 15:00

I am working on developing a REST API using ExpressJS, NodeJS, Mongoose and Mocha.

The thing is that I have an app.coffee file, thats responsible for setting up Expr

6条回答
  •  感动是毒
    2020-12-13 15:41

    The app.listen method takes a callback that runs when everything is ready. So, you need to be able to pass the done callback there. Something like

    before (done) ->
      var app = require(__dirname + '/../src/app')
      app.listen(3000, done)
    

提交回复
热议问题