shelfio / jest-mongodb

Jest preset for MongoDB in-memory server
MIT License
587 stars 83 forks source link

useSharedDBForAllJestWorkers: false is not working and all jest workers are getting the same database URI #430

Closed itai-gendler closed 7 months ago

itai-gendler commented 10 months ago

Hello.

First thanks for such a great library.

I am trying to run my jest tests suites in parallel but although following the docs each worker gets the same mongo uri in the global.__MONGO_URI__

i can easily see this because i am printing the uri and all suites are getting the same uri.

i am calling the connectToMongo from beforeAll in each suite.

i have tried to execute the tests in this repo but i am unable to get them to even run.

code code-mongo code-3

bene-we commented 8 months ago

@itai-gendler have you tried moving the useSharedDBForAllJestWorkers prop one level up, like in the docs?

module.exports = {
  mongodbMemoryServerOptions: {
    binary: {
      skipMD5: true,
    },
    autoStart: false,
    instance: {},
  },

  useSharedDBForAllJestWorkers: false,
};
itai-gendler commented 7 months ago

Thanks @bene-we this worked!!!