jest-mongodb
jest-mongodb copied to clipboard
Option to disable `jest-mongodb` and use real database
Add and option to disable jest-mongodb and use real database, so it's possible to use the same tests both in local and/or unit tests, and for a real deployment like integration tests.
Implementation would be easy, just a matter creating the MongodbMemoryServer instance inside https://github.com/shelfio/jest-mongodb/blob/ea02ede2bd7abe760f4506a5089fd0b1dd44f265/setup.js#L11 after checking for a condition, and later check on https://github.com/shelfio/jest-mongodb/blob/ea02ede2bd7abe760f4506a5089fd0b1dd44f265/teardown.js#L3 if global.__MONGOD__ has been set... Problem is what condition to use. Obvious one would be an environment variable, like if process.env.MONGO_URL is already set, but maybe overwritting it by jest-mongodb could be a valid use case, for example if it's already set in a .env file... Maybe a DISABLE_JEST_MONGODB environment variable?