模拟/测试Mongodb数据库Node.js

编程入门 行业动态 更新时间:2024-10-27 16:30:04
本文介绍了模拟/测试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.

谢谢

推荐答案

有一些

mongodb. github/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

本文发布于:2023-10-19 00:07:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1505829.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   测试   js   Mongodb   Node

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!