Skip to content

Releases: alonronin/mockingoose

Support lean

22 Jan 14:02
Compare
Choose a tag to compare

now mongoose supports mongoose query lean:

it('should lean', () => {
      mockingoose.User.toReturn([{ name: '2' }]);

      return User
        .find()
        .lean()
        .then(result => {
          expect(result[0]).toMatchObject({ name: '2' });
        });
    });

thanx @yonatanhg for the issue.

Supports mongoose.createConnection

22 Jan 13:17
Compare
Choose a tag to compare
v2.7.1

:bookmark: 2.7.1

Returns Error from mock with `save` operation

19 Jan 14:19
Compare
Choose a tag to compare

Count Opertor

09 Jan 18:53
Compare
Choose a tag to compare

Support count operator. Thanks @kevinfez for the issue.

Example

it('should count', () => {
  const count = 2;
  mockingoose.User.toReturn(count, 'count');

  return User.count().then(result => {
    expect(result).toBe(count);
  });
});

v2.4.0

05 Nov 09:35
Compare
Choose a tag to compare

Connect function returns a Pormise, thanks to @devinus

Mockingoose v2.3.0

29 Sep 14:17
Compare
Choose a tag to compare

Now supports empty responses, thanks to @noamokman for the PR.

mockingoose.User.toReturn([]);

return User
.find()
.then(result => {
  expect(result).toHaveLength(0);
})

or

mockingoose.User.toReturn(null);

return User
.findOne()
.then(result => {
  expect(result).toBeFalsy();
})