Jest did not exit one second after the test run has completed using express

前端 未结 5 1832
孤独总比滥情好
孤独总比滥情好 2021-02-05 14:24

I\'m using JEST for unit testing my express routes.

While running the yarn test all my test case are getting passed, but I\'m getting an error



        
5条回答
  •  花落未央
    2021-02-05 15:07

    This worked for me

    const mongoose = require('mongoose');
        afterAll(async(done) => {
      // Closing the DB connection allows Jest to exit successfully.
      try {
        await mongoose.connection.close();
        done()
      } catch (error) {
        console.log(error);
        done()
      }
      // done()
    })
    

提交回复
热议问题