Replies: 1 comment 2 replies
-
i recommend to not use
without knowing the model, i dont know if i can help further - it may be that the model is registered on another mongoose instance or connection than the one connected
are you trying to mock the function for the
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In attempting to unit test a function in a controller, the model call doesn't see the connection. Mongodb-memory-server report started and connected. I read somewhere that the database is not actually created until data is inserted. I was unable to find and example either in the docs nor google. How can I seed the db (if needed) and what to call to mock it (if needed).
I did see this issue, but I think I am a couple of steps away from knowing how to 'write a script'.
When I put a try/catch around the call in the controller I am receiving is: "Error: MongoNotConnectedError: Client must be connected before running operations"
Controller function I am trying to test
Unit Test File
I feel like I am missing something fundamental but cannot figure out what. All suggestions and assistance appreciated.
Beta Was this translation helpful? Give feedback.
All reactions