Quantcast
Viewing latest article 1
Browse Latest Browse All 7

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 and incredibly unsatisfying.

There are mock libraries in npm:

mongo - https://www.npmjs.com/package/mongomock

mongoose - https://www.npmjs.com/package/mockgoose

If those don't support the features you need, then yes you may need to use the real thing.


Viewing latest article 1
Browse Latest Browse All 7

Trending Articles



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