-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Update Mongoose recipe #2878
Update Mongoose recipe #2878
Conversation
For future reference you don't need to close the PR, you can push more changes to your branch and they'll show up here. With your changes, the recipe now assumes that top-level await is supported. I don't think we can make that assumption. I think you may need to create the server within the |
Oh yes it is, I updated my code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cheers @hamidbae
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call t.context.mongod
instead directly call mongod
and test.after.always
hook missing t
param ?
// First start MongoDB instance | ||
t.context.mongod = await MongoMemoryServer.create(); | ||
// And connect | ||
await mongoose.connect(mongod.getUri()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got error when directly call mongod to get Uri. I think it should be t.context.mongod.getUri()
?
@@ -117,8 +116,8 @@ Finally disconnect from and stop MongoDB when all tests are done: | |||
|
|||
```js | |||
test.after.always(async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here I think I should add t
as parameter ?
Well spotted, thanks @hamidbae. Fixed in dc405ef. |
Continue previous bad pr, I really sorry about that. Actually this is the changes that I mean before.
My problem is cannot get mongo uri with your current readme on https://github.com/avajs/ava/blob/main/docs/recipes/endpoint-testing-with-mongoose.md.
After doing some search I found update rules to get mongo uri but no update on readme.
So I made this update to make it clear.
Also if I am mistaken, please don't hesitate to reach me out or just ignore this pr ya. Thanks:).