Reputation: 37
I want to make some unit tests on my nodejs app in order to test the insertion of a user on a database or the read of a user from the database.
I'm using Objection.js such an ORM and I searched through the net how to do these Test, thus I found Sinon to mock a database or a model.Concerning this issue I found also this question Mocking database in node.js?.
For example if I have a table Users
contains 10 users, is there any solutions to get all the rows of such table for example of fetch if a user exists in the table? I don't really understand the concept of mocking and if it is the suitable solution to make such tests?
Upvotes: 0
Views: 122
Reputation: 598
There are lots of libs for unit testing of NodeJS such as Moca, Chai, Jasmine.
here is some tutorial link:
https://www.codementor.io/davidtang/unit-testing-and-tdd-in-node-js-part-1-8t714s877
https://blog.risingstack.com/node-hero-node-js-unit-testing-tutorial/
Upvotes: 2