腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
文章
问答
(9999+)
视频
沙龙
0
回答
Stub
Mongoose
查找
方法
、
、
、
model: 'Unit', select: 'title'}) .lean()}it('should test getOpenTickets', async() => { exec: fu
浏览 4
提问于2017-12-08
得票数 2
6
回答
使用Sinon进行存根链接的猫鼬调用
、
、
someBooleanProperty").equals(true) .exec(someCallback);var findOneStub = sinon.
stub
(
mongoose
.Model, "findOne");没有用,有什么建议吗?
浏览 11
提问于2015-01-08
得票数 13
回答已采纳
3
回答
用Sinon固执猫鼬模型
、
、
我试图对这个对象中使用的猫鼬依赖项进行存根: return new Page(db); var PageSchema =
mongoose
.modelpageModel.save(); Page.prototype.sa
浏览 8
提问于2013-05-24
得票数 6
回答已采纳
1
回答
如何在
Mongoose
模型中使用存根
方法
?
、
、
、
、
如何存根以下虚构模式的实例
方法
bark?var dogSchema =
mongoose
.Schema({}); bark() { console.log('Woof!')
浏览 2
提问于2016-08-15
得票数 0
回答已采纳
2
回答
用sinon嘲弄/顽固不化猫鼬findById
、
、
、
我试着把我的猫鼬模型,特别是猫鼬的findById
方法
到目前为止,我的情况如下:
mongoose
= require('
mongoose
'), accountStub = sinon.
stub
(
mongoose
.m
浏览 4
提问于2014-03-01
得票数 6
回答已采纳
6
回答
用Sinon截断
Mongoose
模型
、
、
我想为特定模型中的
Mongoose
save
方法
创建一个存根,这样我创建的模型的任何实例都将调用存根,而不是普通的
Mongoose
save
方法
。我的理解是,要做到这一点,唯一的
方法
是像这样将整个模型存根:不幸的是,这一行代码导致我的测试抛出以下错误: TypeError
浏览 0
提问于2012-07-04
得票数 27
回答已采纳
0
回答
Mockgoose:如何在
mongoose
中模拟错误?
、
、
、
、
虽然mockgoose在模拟
mongoose
方面做了很好的工作,以便我可以围绕它进行测试,但我没有找到一种
方法
来推动它使调用失败,所以我可以测试错误处理逻辑。 }); var
stub
/test.js', { '
mongoose
'
浏览 2
提问于2016-07-11
得票数 3
回答已采纳
1
回答
如何存根
mongoose
模型保存*和*它的保存挂钩
、
、
为什么这段代码会失败,并显示"you have have stubbed“错误消息,而不是只打印"Save
stub
fail”并退出?var
mongoose
= require('
mongoose
'), modelSchema, modelInstancemodelSchema.pre('save', function (next) { throw new Erro
浏览 1
提问于2015-05-15
得票数 1
1
回答
在Model#save ()处理中没有调用猫鼬Promise.all
、
、
、
/models/postModel'); var
mongoose
= require('
mongoose
');exports.create_comment =为了
浏览 2
提问于2017-05-04
得票数 2
回答已采纳
0
回答
阻止proxyquire调用原始代码?
、
、
、
、
我正在尝试围绕
mongoose
模型进行测试。要测试的代码: Test = require('.) => { var
stub
= {/model/Test.js':
stub
.
浏览 6
提问于2016-07-12
得票数 2
回答已采纳
1
回答
如何模拟正在测试的函数内部调用的函数?
、
、
、
、
我有一个注册函数,它将我的用户保存到
mongoose
。在测试时,我不希望用户实际被保存到DB中,所以我想重写
mongoose
保存
方法
。/user'import
mongoose
from '
mongoose
' passwo
浏览 3
提问于2018-08-11
得票数 2
回答已采纳
1
回答
测试具有依赖于另一个模式的验证的猫鼬模式。
、
、
、
、
const chai = require('chai');
mongoose
.connect(dsn, { useUnifiedTopology= require('
mongoose
'); cons
浏览 2
提问于2020-11-02
得票数 1
回答已采纳
1
回答
Express:单元测试控制器,它调用模型
mongoose
模型,而不真正调用数据库
、
、
、
、
控制器本身称为
mongoose
模型。我需要在不调用数据库且独立于路由器的情况下对控制器进行单元测试。 } }页面模型:const pageSchem
浏览 2
提问于2020-09-27
得票数 0
4
回答
使用
Mongoose
进行单元测试
、
、
、
、
我是第一次接触Node.js、
Mongoose
和在这个环境中进行测试。我在一个单独的文件中声明了以下模式。Issue =
mongoose
.model("Issue", { date: String, name: String,}); 然后我有了这个
方法
,它只返回MongoDB集合中的所有Issue实例。
浏览 46
提问于2013-10-10
得票数 18
1
回答
如何存根未在文件中声明的对象的实例
、
、
、
Banner is not defined‘ const sinon = require('sinon');const
mongoose
= require('
mongoose
');const assert = require('chai').assert; describe.onlybefore((done)
浏览 19
提问于2019-10-12
得票数 1
2
回答
蒙鹅模型的虚属性顽固化
、
、
是否有一种
方法
来存根蒙鹅模型的虚拟属性? var p = new Problem(); sinon.
stub
(p, 'difficu
浏览 3
提问于2013-08-23
得票数 2
回答已采纳
1
回答
无法读取未定义的属性'model‘
、
、
这是我的foree‘into
mongoose
方法
。任何建议都是非常感谢的。我正试图让我的头脑围绕着一个简单的
mongoose
.method。托尼
Mongoose
方法
(
mongoose
模式文件的底部):this.model('User').findOneval);}; module.exports =
mongoose
.model('
浏览 4
提问于2019-01-27
得票数 1
1
回答
如何使用
mongoose
查询mongo文档?
、
、
、
、
MongoDB文档包含一个对象数组,如果我想要在数组中
查找
和删除具有某些特定值的对象,那么查询这些文档的最佳
方法
是什么; 下面是文档模式的一个示例 const
mongoose
= require("
mongoose
"); user: { required: true,
浏览 10
提问于2021-09-29
得票数 2
回答已采纳
1
回答
不能存根不存在自己的属性findOne
、
、
、
、
试图对我的用户猫鼬模型的findOne
方法
进行存根,但是得到了错误Cannot
stub
non-existent own property findOne。我在连接器中使用findOne
方法
来获取用户,这很好。只是在测试中,它说该
方法
不存在:const user = await UserModel .
stub
(UserModel.prototype, 'findO
浏览 0
提问于2018-08-11
得票数 1
1
回答
模拟路由中的
mongoose
save()错误
、
、
在尝试了各种
方法
来测试路由的
mongoose
save()抛出后,我真的不确定应该如何做。我的目标是用istanbul实现100 %的覆盖率。以下是核心设置:let
mongoose
= require('
mongoose
'); createdAt: { type: Date, default: Date.now }, updatedAt:
浏览 0
提问于2018-05-23
得票数 0
点击加载更多
热门
标签
更多标签
云服务器
ICP备案
对象存储
实时音视频
云直播
活动推荐
运营活动
广告
关闭
领券