Skip to content
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

Add entry point that mocks global MongoDB #150

Open
LinusU opened this issue Aug 17, 2021 · 0 comments
Open

Add entry point that mocks global MongoDB #150

LinusU opened this issue Aug 17, 2021 · 0 comments

Comments

@LinusU
Copy link
Collaborator

LinusU commented Aug 17, 2021

Currently we are using something like this to test our API with a mocked version of MongoDB, without having to specifically having to code the app to know anything about Mongo Mock:

const mock = require('mongo-mock')
const real = require('mongodb')

mock.max_delay = 0
real.MongoClient = mock.MongoClient
real.ObjectId = mock.ObjectId

I think that it could be a benefit to add this as an entry point to this package, the same way that e.g. dotenv/config works. Providing this instead of letting every end users write their own has some benefits:

  • Easy to run any MongoDB app with node -r mongo-mock/global app.js
  • End user doesn't need to figure out which properties needs patching
  • Works even if the end user uses ESM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant