Answer the question
In order to leave comments, you need to log in
How to test the correctness of functions that write to MongoDB?
There is a Node.JS backend with MongoDB and GraphQL API. What libraries should be used to test database writing functions?
As I understand it, using easy-graphql, you can only test the correctness of schemas (that correct data is supplied to query or mutations)?
Answer the question
In order to leave comments, you need to log in
- raise the test database (you can docker, you can https://docs.mongodb.com/manual/core/inmemory/). clean or with the required initial data.
- call your functions.
- make a request to the database, compare the answer with what should be there.
In your case, perhaps it makes sense not to check the entry to the database, but to do full integration testing - instead of querying the database, pull the necessary queries from graphql. So you check the whole chain. Further - a question of adequacy of tests which you write.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question