sinon-chai相关内容
我在这里的NodeJS中隔离了我面临的问题。依赖函数上的SINON存根不能按预期工作。我没有得到我在这里错过的东西。感谢你的帮助。以下是示例代码。 sinonTest.js "use strict"; function getSecretNumber () { return 44; } function getTheSecret () { return `The secret
..
我在用SINON和Chai编写测试时遇到了问题。 我正在尝试检查是否对间谍调用了函数并获取 ";错误:无效的Chai属性:calledOnce"; 我正在使用相同的测试依赖项在另一个项目中执行相同的操作,没有任何问题。 var udpSocketStub = this.sandbox.spy(udpSocket, 'send'); expect(udpSocket
..
我需要测试此函数: //user.js function getUser(req, res, next){ helper.get_user(param1, param2, (err, file) => { if (err) return next(err); } 这是我的测试函数: it ("failed - helper.get_u
..
我正在尝试测试一个调用模块 cors 的函数.我想测试 cors 是否会被调用.为此,我必须存根/模拟它. 这是函数cors.js const cors = require("cors");const setCors = () =>cors({origin: 'http//localhost:3000'});module.exports = { setCors } 我测试此类功能的想法类
..
我正在监视的功能,接收对象作为参数.我需要断言该函数是用对象的某些属性调用的. 例如:我的SUT具有: function kaboom(){fn({foo:"foo",bar:'bar',zap:function(){...},dap:是的});} 在我的测试中,我可以这样做: fnStub = sinon.stub();kaboom();期望(fnStub)被调用; 并且有
..
所以我有一个文件user-database,看起来像这样: export function foo(id: number): Promise { return new Promise((resolve, reject) => { findSomething(id) .then((data) => { //do somethi
..
我需要测试此功能: //user.js function getUser(req,res,next){ helper.get_user(param1, param2, (err,file)=>{ if (err) return next(err);} 我的测试功能: it ("failed - helper.get_user throws e
..
我正在尝试使用sinon测试localStorage.基本上,我是单元测试的新手,所以这可能很基础. 更新 我设法解决了这个问题,但是现在它给了我一个新的错误Should wrap property of object 测试 describe('Initial State', () => { it('should set the initial state for
..
我想使用sinon存根来异步测试事件发射器. 我希望存根在调用后调用回调. 我以为stub.yields是我想要的,但不是.有没有一种整齐的方法可以做到这一点? it('asynchronously emits finish after logging is complete', function(done){ const EE = require('event
..
我正在对带有角框架的打字稿编写的项目进行单元测试,方法是将缘故与mocha和chai框架一起应用.对象的接口为: interface ISolution { _id: string; paymentFrequency: PaymentFrequency; }; 而PaymentFrequency类型定义为: type PaymentFrequency = 'MONT
..
我有在Karma下运行的单元测试,并且正在使用sinon-chai库. 在Mac上一切正常,但是现在我移到Windows了,发生了以下错误: C:\Users\mchambe4\dev\simple\client>node ./node_modules/gulp/bin/gulp.js unit-tests-dev [16:29:31] Using gulpfile ~\dev\sim
..