mongodb-memory-server: MongoParseError: URI malformed, cannot be parsed
async function test() {
const mms = new MongoMemoryServer()
const mongoUri = await mms.getConnectionString()
return MongoClient
.connect(mongoUri, { useNewUrlParser: true })
.then(async (client) => {
const testDb = client.db(await mms.getDbName())
console.log('Successful Test DB Connection to ', mongoUri)
testDb.close = () => {
if (client) client.close()
if (mms) mms.stop()
}
return testDb
})
.catch(err => console.error(err))
}
getConnectionString seems to be returning an unsupported URI format. It still connects successfully, but seeing this in the terminal over and over is annoying.
"mongodb-memory-server": "^3.1.1",
"mongodb": "^3.1.11",
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 21 (1 by maintainers)
Commits related to this issue
- fix: fix description & usage of "dbName" in mongo URI BREAKING CHANGE: `getUri`'s parameter got changed to what the actual definition is, and uses "admin" by default fixes #141 — committed to nodkz/mongodb-memory-server by hasezoey 3 years ago
- fix: change "generateDbName" to return an empty string by default BREAKING CHANGE: `getUri`'s parameter got changed to use ""(empty) by default fixes #141 — committed to nodkz/mongodb-memory-server by hasezoey 3 years ago
🎉 This issue has been resolved in version 7.0.0 🎉
The release is available on:
Your semantic-release bot 📦🚀
🎉 This issue has been resolved in version 7.0.0-beta.46 🎉
The release is available on:
Your semantic-release bot 📦🚀
btw, the workaround for now is to add an parameter to
getUri
calls to define an custom database (example:server.getUri("authDB")
)changing target of the issue:
-
is not allowed in database names (or at least it cannot be parsed?)Note: its for 7.x, because it is an kinda breaking change