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

The Jest example in README does not work #42

Closed
songguoqiang opened this issue Jan 23, 2018 · 2 comments
Closed

The Jest example in README does not work #42

songguoqiang opened this issue Jan 23, 2018 · 2 comments

Comments

@songguoqiang
Copy link

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);
  });
@nodkz
Copy link
Collaborator

nodkz commented Jan 23, 2018

Thanks for catching this! 👌
Wanna make a PR for your fix?

@nodkz nodkz closed this as completed in bd275e7 Jan 29, 2018
@songguoqiang
Copy link
Author

songguoqiang commented Jan 30, 2018 via email

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