-
-
Notifications
You must be signed in to change notification settings - Fork 754
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
Changing mongodb connection string causes generated tests to fail #1718
Comments
I don't think this is a Feathers specific issue. The connection initialization probably wasn't successful. One thing that could be improved in the generated connection file (
|
I think the issue is actually that mongoClient ends up as In the before hook of the test, I added I then added
The test then passes, as the db connection is ready. In users.class.js we have
I'm still struggling to get my head around promises a little, but I think this essentially just adds another .then to the promise chain - so again, by the time we get to the end of this file, there is no guarantee that mongoClient is anything but a pending promise. I changed the code to this just to prove this to myself:
Which results in
So in the tests, where we have Edit: Changed some stuff in this post to make what is going on more clear (I hope) |
The promise will be resolved in the before(async () => {
await app.get('mongoClient');
}); In each test. |
Thanks for the response. I will definitely do an It would be nice if there was default way to wait for all promises in the app object to be resolved before it was useable, in the case of having many |
Yep, this will be possible in the next version. The issue for this is #509 so going to close this one. |
Steps to reproduce
I generate a new app using the Feathers CLI, using all the default selections except for making the users service type 'mongodb'. I set up both a local mongodb instance and one running elsewhere (I'm using the Atlas hosted database service). Running
npm test
without changing anything works, all tests pass. Next I change the default connection string from localhost to point at my external database and runnpm test
again.The connection string looks like: "mongodb+srv://[username]:[password]@testing-cluster-ziimk.mongodb.net/test"
Expected behavior
All tests should pass, same as if I was using the local database
Actual behavior
The test 'authenticates user and creates accessToken' fails with
TypeError: Cannot read property 'find' of undefined
.I know that the database can be accessed, because if I do
npm start
and create a user with a POST request I get a HTTP 201 response and the user is successfully created in the remote database.I have noticed that I get the following warning after
npm start
:DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
but I don't think this is related.System configuration
Tried on both Ubuntu and Windows 10.
On Ubuntu, I have:
Feathers 4.2.3
Node v10.17.0
NPM 6.11.3
MongoDB 4.0
The text was updated successfully, but these errors were encountered: