title: How to stub Mongoose methods with Sinon to test DAO?
body: <p>Here is my Node unit test-case for a DAO method that returns a list of Category objects. Category is the name of my model. However, when I run this code, it is getting stuck. </p>
  
  <pre><code>describe('findAllCategories', function () {
      it('should find all categoriess', function () {
          var stub = sinon.stub(Category, 'find');
          stub.callsFake(() =&gt; {
              return Promise.resolve(allCat);
          });
          categoryDao.findAllCategories().then(response =&gt; {
              assert.lengthOf(response, 1);
          })
              .catch((error) =&gt; {
                  console.log(error);
                  assert.isDefined(error);
              });
          stub.callsFake(() =&gt; {
              return Promise.reject('');
          });
          categoryDao.findAllCategories().then(response =&gt; {
              assert.lengthOf(response, 1);
          }).catch((err) =&gt; {
              console.log(err);
              assert.isDefined(err);
          });
      });
  });
  </code></pre>
  
  <p>Any way around?</p>