title: Unit testing the instance of Sequelize Model
body: <p>I have the following code:</p>
  
  <pre><code>async save(id: string) {
   const person = await PersonModel.findOne({
    where: { id: id },
   });
  
   if (!person) {
    await PersonModel.create({
      id: '2345',
      name: 'John Doe',
      age: 25
    });
    return;
   }
  
   await person.increment({ age: 15 });
  }
  </code></pre>
  
  <p>Now, I wanted to test person.increment() in which the age will be added with 15. I have the following code to escape the condition that will create a new record for the model.</p>
  
  <pre><code>const findOneFake = sinon.spy(() =&gt; {
    return {}; //returns empty object or true
  });
  
  const proxy = (proxyquire('./path/to/file.ts', {
    './path/to/PersonModel.ts': {
      default: {
        findOne: findOneFake
      }
    }
  })).default;
  
  beforeEach(async () =&gt; {
    await save();
  });
  
  it('should increment age with 15');
  </code></pre>
  
  <p>How am I going to do that? What do I do to test it? I can use sinon.fake() to PersonModel.create or PersonModel.update but I am troubled testing the instance of a Sequelize Model.</p>