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
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() })