Quantcast
Viewing all articles
Browse latest Browse all 7

Answer by christkv for Mocking database in node.js?

There is a general rule of thumb when it comes to mocking which is

Don't mock anything you don't own.

If you want to mock out the db hide it behing an abstracted service layer and mock that layer. Then make sure you integration test the actual service layer.

Personally I've gone away from using mocks for testing and use them for top to bottom design helping me drive development from the top towards the bottom mocking out service layers as I go and then eventually implementing those layers and writing integration tests. Used as a test tool they tend to make your test very brittle and in the worst case leads to a divergence between actual behavior and mocked behavior.


Viewing all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>