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

Deprecated Mongo connection options in npm page

Open ericsj opened this issue 3 years ago • 4 comments

The following code in the project npm page has deprecated connect() options

beforeAll(async () => { connection = await MongoClient.connect(global.__MONGO_URI__, { useNewUrlParser: true, useUnifiedTopology: true, });

Both connection options used are not present on the reference page

ericsj avatar May 23 '22 12:05 ericsj

@ericsj I have the same problem. Apparently there is no definition in the interface: MongoClientOptions to useNewUrlParser and useUnifiedTopology options

heitorvaldeger avatar May 24 '22 19:05 heitorvaldeger

The following code in the project npm page has deprecated connect() options

beforeAll(async () => { connection = await MongoClient.connect(global.__MONGO_URI__, { useNewUrlParser: true, useUnifiedTopology: true, });

Both connection options used are not present on the reference page

Do you have some workaround for that problem?

VictorMeneghini avatar Nov 26 '22 10:11 VictorMeneghini

m. Apparently there is no definition in the interface: MongoClientOptions to useNewUrlParser and useUnifiedTopology options

I have this same problem can someone resolve this?

josanjohnata avatar Jan 28 '23 23:01 josanjohnata

m. Apparently there is no definition in the interface: MongoClientOptions to useNewUrlParser and useUnifiedTopology options

I have this same problem can someone resolve this?

I can resolve with that:


const mongoSetup = require('@shelf/jest-mongodb/setup'); 

module.exports = async function globalSetup() {
  await mongoSetup();
  // process.env.MONGO_URL is now set by
  // https://github.com/shelfio/jest-mongodb/blob/fcda766bfa433644a7383993467ccaa06dfea28b/setup.js#L26
  await mongoose.connect(process.env.MONGO_URL, {
    useNewUrlParser: true,
    useUnifiedTopology: true,
    useCreateIndex: true,
    useFindAndModify: false,
  });
};

josanjohnata avatar Jan 28 '23 23:01 josanjohnata

Providing some updates on this issue According to this issue (https://github.com/mongodb/node-mongodb-native/pull/3792), these options were disabled in version 4.0.0 of the mongodb library.

heitorvaldeger avatar Apr 25 '24 02:04 heitorvaldeger