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?
            Asked
            
        
        
            Active
            
        
            Viewed 96 times
        
    0
            
            
        
        user3618284
        
- 37
 - 5
 
1 Answers
2
            
            
        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/
        Osama Bari
        
- 597
 - 3
 - 15
 
- 
                    But there is no useful link to make a test of database – user3618284 Sep 27 '17 at 10:56