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
yarn test
My problem was solved by this code:
beforeAll(done => { done() }) afterAll(done => { // Closing the DB connection allows Jest to exit successfully. mongoose.connection.close() done() })