I am using Express to build a REST API. The code is divided, as should be, in Routes/Models/Controllers (no views, it's just JSON)
The controllers take care of the logic : they make request to the database and build the responses. To me, this is the main thing to test in my application.
Now, how should I test my controllers ?
I have read that writing atomic tests is the best way to go, so I guess I should clear the database, run migrations and seed the database before every single test (which is composed of making a request to the controller + checking the response)... but this takes ages, even for a very small number of tests ! If I do it this way, hooking the tests to git seems a really bad idea, and the whole idea of testing them breaks down.
Aucun commentaire:
Enregistrer un commentaire