When running a feathers app with MongoDB, how can one go about unit testing without having to connect to an actual MongoDB?
The documentation around test-database-setup (and this article) mentions that one can specify a local file path for nedb in the config/test.json file like so:
{
"nedb": "../test/data"
}
The documentation and article also mentions that "The same thing can be done with connection strings for other databases.", but this does not seem to work for MongoDB.
I tried setting the following in the config/test.json file:
{
"mongodb": "../test/data"
}
Which MongoDB doesn't seem to like.
Is there a recommended way by Feathers to mock out MongoDB? Looks like there are options like mongodb-memory-server and mongo-mock, but don't want to sink too much time into those if Feathers has a better way of achieving this.
Thanks!
System configuration
Module versions (especially the part that's not working):
Question
When running a feathers app with MongoDB, how can one go about unit testing without having to connect to an actual MongoDB?
The documentation around test-database-setup (and this article) mentions that one can specify a local file path for
nedb
in theconfig/test.json
file like so:The documentation and article also mentions that "The same thing can be done with connection strings for other databases.", but this does not seem to work for MongoDB.
I tried setting the following in the
config/test.json
file:Which MongoDB doesn't seem to like.
Is there a recommended way by Feathers to mock out MongoDB? Looks like there are options like mongodb-memory-server and mongo-mock, but don't want to sink too much time into those if Feathers has a better way of achieving this.
Thanks!
System configuration
Module versions (especially the part that's not working):
"@feathersjs/adapter-commons": "^5.0.23"
"@feathersjs/feathers": "^5.0.23"
"@feathersjs/mongodb": "^5.0.23"
"mongodb": "^6.4.0",
NodeJS version: v20