mockingoose
Advanced tools
Comparing version 2.13.0 to 2.13.1
{ | ||
"name": "mockingoose", | ||
"version": "2.13.0", | ||
"version": "2.13.1", | ||
"description": "A Jest package for mocking mongoose models", | ||
@@ -30,12 +30,12 @@ "main": "./lib", | ||
"devDependencies": { | ||
"@types/jest": "^24.0.11", | ||
"@types/mongoose": "^5.3.23", | ||
"jest": "^24.5.0", | ||
"prettier": "^1.16.4", | ||
"ts-jest": "^24.0.0", | ||
"ts-node": "^8.0.3", | ||
"tslint": "^5.14.0", | ||
"@types/jest": "^24.0.13", | ||
"@types/mongoose": "^5.5.5", | ||
"jest": "^24.8.0", | ||
"prettier": "^1.18.2", | ||
"ts-jest": "^24.0.2", | ||
"ts-node": "^8.2.0", | ||
"tslint": "^5.17.0", | ||
"tslint-config-prettier": "^1.18.0", | ||
"tslint-plugin-prettier": "^2.0.1", | ||
"typescript": "^3.3.4000" | ||
"typescript": "^3.5.1" | ||
}, | ||
@@ -42,0 +42,0 @@ "peerDependencies": { |
@@ -195,2 +195,26 @@ # Mockingoose [](https://circleci.com/gh/alonronin/mockingoose/tree/master) | ||
- you can mock `.populate` in your mocked result just be sure to change | ||
the `Schema`'s path to appropriate type (eg: `Object` | `Mixed`): | ||
```js | ||
User.schema.path('foreignKey', Object); | ||
const doc = { | ||
email: 'test@mail.com', | ||
foreignKey: { | ||
_id: '5ca4af76384306089c1c30ba', | ||
name: 'test', | ||
value: 'test', | ||
}, | ||
name: 'Name', | ||
saveCount: 1, | ||
}; | ||
mockingoose(User).toReturn(doc); | ||
const result = await User.find(); | ||
expect(result).toMatchObject(doc); | ||
``` | ||
- no connection is made to the database (mongoose.connect is jest.fn()) | ||
@@ -204,7 +228,7 @@ | ||
- `mockingoose.ModelName` is deprecated, `mockingoose(Model)` is the now the recommended usage, with `Model` being a Mongoose model class. | ||
- `mockingoose.ModelName` is deprecated, `mockingoose(Model)` is the now the recommended usage, with `Model` being a Mongoose model class. | ||
Alternatively, you may pass a string with the model name. | ||
- `mockingoose(Model).toReturn((query) => value)` can now take also take a function as a parameter. | ||
- `mockingoose(Model).toReturn((query) => value)` can now take also take a function as a parameter. | ||
@@ -211,0 +235,0 @@ The function is called with either a [Query](https://mongoosejs.com/docs/api.html#Query) or [Aggregate](https://mongoosejs.com/docs/api.html#Aggregate) object from Mongoose, depending on the request. This allows tests to ensure that proper queries are sent out, and helps with regression testing. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
28047
236
0