Mock/Test Mongodb Database Node.js

后端 未结 3 1263
离开以前
离开以前 2021-02-05 03:36

I am learning nodejs and I have a mongodb database with which i have to interact with. I am currently thinking of using mocha for a unit test framework and zombie.js for a acce

相关标签:
3条回答
  • 2021-02-05 04:00

    There are some

    http://mongodb.github.com/node-mongodb-native/github/github.html#test-helpers-and-libraries

    but you might want to just search on github or ask in the google group as well.

    0 讨论(0)
  • 2021-02-05 04:06

    If your database access is a separate module, you can mock out the module or parts of the module (e.g., the configuration part) using one of the following:

    • sinon
    • rewire
    • horaa
    • sandboxed-module

    The answers to the following related question lists a number of possible solutions/approaches: How do you mock MySQL (without an ORM) in Node.js?

    0 讨论(0)
  • 2021-02-05 04:16

    In order to spin up a real in-memory mongodb for testing, https://github.com/nodkz/mongodb-memory-server helps as well.

    0 讨论(0)
提交回复
热议问题