jest-mongodb icon indicating copy to clipboard operation
jest-mongodb copied to clipboard

Is it possible to run 2 different mongodb-memory-server in the same test?

Open PauloFavero opened this issue 3 years ago • 0 comments

Hi everyone,

I have a test case where I need to connect simultaneously in two different dbs. Let's say I have a db_A and db_B. I need to query some data from db_A and then query more data from db_B. The result needs to be a combination of those queries.

My jest MongoDB config is as follows:

module.exports = {
  mongodbMemoryServerOptions: {
    instance: {
      dbName: 'jest'
    },
    binary: {
      version: '4.4.0',
      skipMD5: true
    },
    autoStart: false
  }
}

Is there a way where I can modify this config to have 2 dbs instances? If yes, what would be the procedures to open the connection? I believe that the MONGO_URL won't work in that case.

Thanks

PauloFavero avatar Jul 29 '22 14:07 PauloFavero