Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tested app unable to connect to mock db #155

Open
chengtangzheng2021 opened this issue Oct 20, 2022 · 1 comment
Open

tested app unable to connect to mock db #155

chengtangzheng2021 opened this issue Oct 20, 2022 · 1 comment

Comments

@chengtangzheng2021
Copy link

chengtangzheng2021 commented Oct 20, 2022

The line of process.env.MONGO_URL = uri; passing connection string to the tested app, in the below connection code, but the app using this connection url get connection refused.

const connect = async () => {
var mongodb = require('mongo-mock');
var uri = 'mongodb://localhost:27017/myproject';
process.env.MONGO_URL = uri;
process.env.MDB_NAME = 'PricerDB_EMEA';
var MongoClient = mongodb.MongoClient;
MongoClient.connect(url, {}, function (err, client) {
db = client.db();
var collection = db.collection('adjustmentsDetails');
collection.insertOne({ "startOn": new Date("2020-07-10 15:00:00.000") })
})
}

@LinusU
Copy link
Collaborator

LinusU commented Dec 1, 2022

get connection refused.

This library doesn't actually connect to anything, so it shouldn't be able to give you "connection refused"

Could you post the stacktrace of the error you are getting?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants