Mocking database in node.js?

前端 未结 6 1578
情歌与酒
情歌与酒 2020-11-29 18:45

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

6条回答
  •  臣服心动
    2020-11-29 19:22

    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 script that creates the db file and cleans it up after.

提交回复
热议问题