title: Jest not closing because of Mongoose.model
body: <p>I am trying to create my first test with jest. </p>
  
  <p><strong>user_model_test.js</strong></p>
  
  <pre><code>const mongoose = require('mongoose')
  const User = require('../user_model')
  
  
  describe('user model tests', () =&gt; {
    beforeAll( async () =&gt; {
      await mongoose.connect('mongodb://localhost/supertest21')
    })
    afterAll( async () =&gt; { 
      await mongoose.connection.close()
    })
  
    it("has a module", () =&gt; {
      expect(User).toBeDefined()
    })
  })
  </code></pre>
  
  <p><strong>user_model.js</strong></p>
  
  <pre><code>const mongoose = require('mongoose')
  const Schema = mongoose.Schema
  
  const userSchema = new Schema({
    username: {
      type: String,
      required: true
    },
    password: {
      type: String,
      required: true
    },
    email: {
      type: String,
      required: true
    }
  })
  
  const User = mongoose.model('User', userSchema, 'user')
  
  module.exports = User
  </code></pre>
  
  <p>When I run my test, running with <code>--detectOpenHandles</code> I get this error: </p>
  
  <pre><code>Jest has detected the following 1 open handle potentially keeping Jest from exiting:
  
    ●  PROMISE
  
        17 | })
        18 |
      &gt; 19 | const User = mongoose.model('User', userSchema, 'user')
           |                       ^
        20 |
        21 | module.exports = User
  
        at Function.init (node_modules/mongoose/lib/model.js:970:16)
        at Mongoose.Object.&lt;anonymous&gt;.Mongoose.model (node_modules/mongoose/lib/index.js:396:11)
        at Object.&lt;anonymous&gt; (libs/user/user_model.js:19:23)
        at Object.&lt;anonymous&gt; (libs/user/__tests__/user_model_test.js:3:14)
  </code></pre>
  
  <p>I know that there is something to do with the mongoose.model initialization.When I pass the 4th parameter to mongoose.model, to skip initialization, the promise error don't show up but the test never closes and don't show any more errors. Any ideas?</p>