Thanks sneekyjs. I run into the same issue with the latest mongo-memory server 18 and mongo 6. Here is my curated code:
const startDatabase = async () => {
// replaced tutorial statement`const mongo = new MongoMemoryServer();`
// to work with mongodb-memory-server version ^18.15.1
const mongo = await MongoMemoryServer.create();
// replaced tutorial statement `await mongo.getConnectionString();`
// since getConnectionString was deprecated in version ^18.15.1
const mongoDBURL = await mongo.getUri();
// replaced tutorial statement `... await MongoClient.connect(mongoDBURL, {useNewUrlParser: true});`
// since useNewUrlParser was deprecated in mongodb version ^6.0.0
const connection = await MongoClient.connect(mongoDBURL);
database = connection.db();
};