Quantcast
Channel: Mocking database in node.js? - Stack Overflow
Browsing all 7 articles
Browse latest View live

Answer by Michael Cole for Mocking database in node.js?

The purpose of mocking is to skip the complexity and unit test own code. If you want to write e2e tests then use the db. Writing code to setup/teardown a testing DB for unit testing is technical debt...

View Article



Answer by Uri for Mocking database in node.js?

I had this dilemma and chosen to work with a test DB and clean it every time the test begins. (how to drop everything: https://stackoverflow.com/a/25639377/378594) With NPM you can even make a test...

View Article

Answer by PositiveGuy for Mocking database in node.js?

I don't agree with the selected answer or other replies so far. Wouldn't it be awesome if you could catch errors spawned by the chaotic and many times messy changes made to DB schemas and your code...

View Article

Answer by cirrus for Mocking database in node.js?

My preferred approach to unit test DB code in any language is to access Mongo through a Repository abstraction (there's an example here http://iainjmitchell.com/blog/?p=884). Implementations will vary...

View Article

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...

View Article


Answer by slebetman for Mocking database in node.js?

I don't think database related code can be properly tested without testing it with the database software. That's because the code you're testing is not just javascript but also the database query...

View Article

Mocking database in node.js?

How would I mock out the database in my node.js application, which in this case uses mongodb as the backend for a blog REST API ? Sure, I could set the database to a specific testing -database, but I...

View Article
Browsing all 7 articles
Browse latest View live


Latest Images