Releases: alonronin/mockingoose
Releases · alonronin/mockingoose
Support lean
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
v2.7.1 :bookmark: 2.7.1
Returns Error from mock with `save` operation
thanks @mikeyGlitz for the issue.
Count Opertor
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
Mockingoose v2.3.0
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();
})