You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried out the Jest example in the README and it does not work. When I ran some test, there are some error message saying "failed to connect on first connect".
The problem is at this line
mongoose.connect(mongoUri, opts, (err) => {
if (err) console.error(err);
});
Since mongoose.connect() returns a promise, we need to call it with await such that the call only returns when the connection is done.
So it should be something like
await mongoose.connect(mongoUri, opts, (err) => {
if (err) console.error(err);
});
The text was updated successfully, but these errors were encountered:
I tried out the Jest example in the README and it does not work. When I ran some test, there are some error message saying "failed to connect on first connect".
The problem is at this line
Since
mongoose.connect()
returns a promise, we need to call it withawait
such that the call only returns when the connection is done.So it should be something like
The text was updated successfully, but these errors were encountered: