-
-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MongoError differ between mongodb-memory-server and vanilla mongod #78
Comments
I think that this difference in error messages depends on mongodb version. If your testing and production versions of mongodb are the same, then you need to try make storageEngine the same. By default it is in memory. So if it helps, please put here your solution for future googlers. PS. You may spin app for some tests regular mongo instance, but for other tests - default in memory for spead. |
Ok, cool! I have the same version but not the same engine. I'm going to try that. Keep you posted. |
Confirming that changing the engine to new MongodbMemoryServer({
binary: {
version: '4.0.2',
},
instance: {
// Available engines:
// storageEngines: [ 'devnull', 'ephemeralForTest', 'mmapv1', 'wiredTiger' ],
storageEngine: 'wiredTiger',
},
}); |
For future googlers: I've published a package that enables you to set the storage engine per test file in Jest. It also enables you to keep a single https://www.npmjs.com/package/jest-environment-mongodb (docs here) |
@lirbank wow great! Please open Pull Request for README.md - add links to your packages under Jest section. |
First off, I totally love mongodb-memory-server - it makes testing models and GraphQL APIs a breeze!
If I log the
errmsg
prop of a MongoError like this:I get this with mongodb-memory-server (Jest):
And this with a vanilla mongod process (Node):
I parse
errmsg
to figure out which index clashed so I can provide a more detailed error message to the client. But since the index part oferrmsg
is not available in the MongoError from mongodb-memory-server I can't write any tests for it.Is there any way around this? Could it be that Jest is the reason for this?
The text was updated successfully, but these errors were encountered: