I'm working on a Nodejs, MongoDB project, and I want to write unit tests for it using Jest, what I need is a structure, or a way or a tool to solve these issues:
** to be able to better explain the question, assume that there are two schemas in my project: User
, Book
-
be able to load a bunch of data before each test, and clear it afterwards(I want a fix and clear database state for each test)
- it is better if the data is loaded from a JSON file.
-
I need to be able to specify the data I want to load for each test. for example, I only need fixtures related to User schema when I want to write unit tests for User api, so I don't want to load fixtures related to Book schema.
-
it would be a bonus point, but not necessary if the database used is in memory database instead of the real MongoDB database.(I want the tests to be fast)
so far I only have found some libraries that solve the first one, but not the second one.
Aucun commentaire:
Enregistrer un commentaire