title: Testing node.js with jest: Cannot spy the save property because it is not a function
body: <p>I am testing a sequelize model with jest and I am getting this error</p>
  <blockquote>
  <p>Cannot spy the save property because it is not a function; undefined
  given instead</p>
  </blockquote>
  <p>save is a builtin method in sequelize so I am wondering why I am getting this error</p>
  <p>my test is:</p>
  <pre><code>describe('...', () =&gt; {
      it('...', () =&gt; {
          jest.spyOn(model, 'save');
          ...
      });
  });
  </code></pre>
  <p>and my function is:</p>
  <pre><code>generateToken() {
      return generateTokenHash(20)
               .then((token) =&gt; {
                    this.token = token;
                    return this.save();
               });
  }
  </code></pre>
  <p>If I remove this line <code>jest.spyOn(model, 'save');</code> I get error but in model's function <code>TypeError: this.save is not a function</code></p>