Skip to content

MongoDB Module

MongoDB is an open source NoSQL database management program. NoSQL is used as an alternative to traditional relational databases. NoSQL databases are quite useful for working with large sets of distributed data. MongoDB is a tool that can manage document-oriented information, store or retrieve information.

Install

npm install @testcontainers/mongodb --save-dev

Examples

it("should work using default version 4.0.1", async () => {
  const mongodbContainer = await new MongoDBContainer().start();

  await checkMongo(mongodbContainer);

  await mongoose.disconnect();
  await mongodbContainer.stop();
});
it("should work using version 6.0.1", async () => {
  const mongodbContainer = await new MongoDBContainer("mongo:6.0.1").start();

  await checkMongo(mongodbContainer);

  await mongoose.disconnect();
  await mongodbContainer.stop();
});