title: Mocking Mongoose model with jest
body: <p>I am trying to mock a mongoose model with <code>jest</code>, but is getting <code>Cannot create property 'constructor' on number '1'</code> error. I was able to reproduce the issue by creating the project with 2 files shown below. Is there a way to mock a mongoose model with <code>jest</code>?</p>
  
  <p>./model.js</p>
  
  <pre><code>const mongoose = require('mongoose')
  const Schema = mongoose.Schema
  
  const schema = new Schema({
    name: String
  })
  
  module.exports = mongoose.model('Test', schema)
  </code></pre>
  
  <p>./model.test.js</p>
  
  <pre><code>jest.mock('./model')
  const Test = require('./model')
  
  // Test.findOne.mockImplementation = () =&gt; {
  //   ...
  // }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code> FAIL  ./model.test.js
    ● Test suite failed to run
  
      TypeError: Cannot create property 'constructor' on number '1'
  
        at ModuleMockerClass._generateMock (../../jitta/sandbox/rest_api/node_modules/jest-mock/build/index.js:458:34)
        at Array.forEach (native)
        at Array.forEach (native)
        at Array.forEach (native)
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>Seems to be a bug in jest.
  <a href="https://github.com/facebook/jest/issues/3073" rel="noreferrer">https://github.com/facebook/jest/issues/3073</a></p>