lirbank / jest-environment-mongodb

Jest environment with a running in-memory MongoDB server
https://www.npmjs.com/package/jest-environment-mongodb
MIT License
3 stars 2 forks source link

Support for mongodb-memory-server version 7.x #14

Open LinusU opened 3 years ago

LinusU commented 3 years ago

Version 7.x added support for my platform (arm64), but it doesn't seem like we are compatible with version 7.x yet. I'm getting the following error:

  ● Test suite failed to run

    "instanceInfo" is undefined

      at assertionInstanceInfo (node_modules/mongodb-memory-server-core/src/MongoMemoryServer.ts:721:38)
      at MongoMemoryServer.getUri (node_modules/mongodb-memory-server-core/src/MongoMemoryServer.ts:632:5)
      at EphemeralEnvironment.setup (node_modules/jest-environment-mongodb/src/index.ts:46:47)

related: https://github.com/nodkz/mongodb-memory-server/issues/213

snitovets commented 3 years ago

from 7.x.x versions MongoMemoryServer instance have to starts manually:

mongod = new MongoMemoryServer();
await mongod.start();

const mongoUri = mongo.getUri();

await mongoose.connect(mongoUri, {
    useCreateIndex: true,
    useNewUrlParser: true,
    useUnifiedTopology: true
});
lirbank commented 3 years ago

Hey, thanks for posting this issue! I personally hold mongodb-memory-server to version 6.x because of the same reasons as you, so this is definitely something I am interested in fixing. Just got to find the time. Would be happy to accept a PR too if you have the inclination.

Potentially related (or not), I have an old branch with some work to support replicasets. Not sure if mongodb-memory-server 7.x makes this any easier, need to explore that when the time comes.

boredland commented 1 year ago

Hi there! Created a PR that should squash all the deprecations at once, including this one. Would appreciate a review! https://github.com/lirbank/jest-environment-mongodb/pull/28