I asked following question on enquiring about the approach I should adopt while writing tests for controllers in REST api application? Within few hours it was downvoted three times but none of the comments written on the question criticized the question or anything about. I'm still confused on what are the possible reasons that my question was downvoted
I'm writing a REST api backend in NODE js, which is based on MVC approach. My api routes directly hit the controllers, which in turn import models which are a wrapper around the methods from a library (DB ORM) called sequelize.
What will be the better approach for writing the unit tests for the controllers,
To include models, with mock DB data, in unit tests of the respective controllers To somehow mock the models and then unit test my controllers without involving the real models at all. If the second approach is better how will I achieve writing these types of Unit tests
Link to the Question