Microservices with Node JS and React | Udemy

PHOTO EMBED

Mon Oct 09 2023 15:03:00 GMT+0000 (Coordinated Universal Time)

Saved by @jalalrafiyev

In the upcoming lecture, we will be setting up our test environment with MongoMemoryServer. If you are using the latest versions of this library a few changes will be required:

In auth/src/test/setup.ts, change these lines:

  mongo = new MongoMemoryServer();
  const mongoUri = await mongo.getUri();
to this:

  mongo = await MongoMemoryServer.create();
  const mongoUri = mongo.getUri();


Remove the useNewUrlParser and useUnifiedTopology parameters from the connect method. Change this:

  await mongoose.connect(mongoUri, {
    useNewUrlParser: true,
    useUnifiedTopology: true,
  });
to this:

  await mongoose.connect(mongoUri, {});


Then, find the afterAll hook and add a conditional check:

afterAll(async () => {
  if (mongo) {
    await mongo.stop();
  }
  await mongoose.connection.close();
});
content_copyCOPY

https://www.udemy.com/course/microservices-with-node-js-and-react/learn/lecture/19119936