模拟/测试Mongodb数据库Node.js [英] Mock/Test Mongodb Database Node.js

查看:100
本文介绍了模拟/测试Mongodb数据库Node.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习nodejs,并且我有一个mongodb数据库必须与之交互.我目前正在考虑将mocha用于单元测试框架,将zombie.js用于接受测试框架.我想知道如何进行对mongodb数据库进行的全面验收测试.是否有一个框架/模块可以帮助用测试数据库替换数据库,或者mocha或zombie.js是否具有可以轻松用于替换数据库的功能.

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 acceptance test framework. I was wondering how could I do full scale acceptance tests which hit the mongodb database. Is there a framework/module that helps with replacing the database with a test database or does either mocha or zombie.js have functionality that can easily be used to replace the database.

在创建数据库对象时,还有一个类似于工厂(而不是固定装置)的框架.

Also is there a framework that is similar to the idea of factories (instead of fixtures) in creating database objects.

我在Rails世界中遇到过类似的概念,在rspec中,有一个spec_helper.rb文件在运行测试之前运行,该文件设置项目配置来确定运行测试时要命中哪个数据库.并且它使用database_cleaner在运行测试之前清除测试数据库.对于工厂,我已经使用Factory girl在Rails世界中再次从数据库架构中创建工厂对象.

A similar concept that I have encountered in the rails world is in rspec, there is a spec_helper.rb file which runs before the tests are run which set the projects configuration to decide which database to hit when running tests. And it uses database_cleaner to clean out the test database before tests are run. For factories, i have used Factory girl to create factory objects from database schema again in the rails world.

谢谢

推荐答案

有一些

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

但是您可能只想在github上搜索或也可以在google组中询问.

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

这篇关于模拟/测试Mongodb数据库Node.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆