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",
What was exactly generated for connection string? And what is your operation system?
Thanks.
closing because stale for over 3 months
Got the same error, mongod.getUri() returned "mongodb://127.0.0.1:38633/a467d6cf-da1b-4050-a833-1c74963e568f"
and got (node:5241) UnhandledPromiseRejectionWarning: MongoParseError: URI malformed, cannot be parsed
Also it seems like process.env.MONGO_URL is returning undefined
Also it seems like
process.env.MONGO_URLis returning undefined
this is never even defined by this package
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
btw, the workaround for now is to add an parameter to getUri calls to define an custom database (example: server.getUri("authDB"))
this is never even defined by this package
sorry my bad, I thought I'm using @shelf/jest-mongodb
btw, the workaround for now is to add an parameter to
getUricalls to define an custom database (example:server.getUri("authDB"))
this worked, i used client = new MongoClient(mongo.getUri('testDB')) and it pretty much works fine
btw I have a question. Is there any issue with using mongodb-memory-server with jest ? cause I'm getting TypeError: Cannot read property 'JSON' of null error, even when connecting to real mongo servers. ( I know it's off topic, but any help is much appreciated)
may depend on how you use jest, but i never had that problem
I'm using jest without even custom configurations
@hasezoey @me-nkr Thank you both! The workaround is noted. Can technically still cause an issue, so I'll leave it up to you guys to keep open or close. Thanks again!
7b986e15dd1c060706b670116739f51bd2ea909b & 840be19d3affae664be61c10ec357292c04922b7 should fix this (7.0.0-beta.46)
where was this used when this problem came up, mongodb driver or mongoose or both? @me-nkr @sam-araiza
asking because it seems the URI format slightly differs between these two (with mongodb /db mean authentication database, and mongoose means default database for the connection & models)
:tada: This issue has been resolved in version 7.0.0-beta.45 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
:tada: This issue has been resolved in version 7.0.0-beta.46 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
7b986e1 & 840be19 should fix this (
7.0.0-beta.46)where was this used when this problem came up, mongodb driver or mongoose or both? @me-nkr @sam-araiza
asking because it seems the URI format slightly differs between these two (with mongodb/dbmean authentication database, and mongoose means default database for the connection & models)
mongodb driver for me. our team is _not_ using mongoose.
7b986e1 & 840be19 should fix this (
7.0.0-beta.46)where was this used when this problem came up, mongodb driver or mongoose or both? @me-nkr @sam-araiza
asking because it seems the URI format slightly differs between these two (with mongodb/dbmean authentication database, and mongoose means default database for the connection & models)
mongo driver for me too
closing because fixed in 7.0.0-beta.46
:tada: This issue has been resolved in version 7.0.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket: