jjzjj

superagent

全部标签

javascript - superagent 和 nock 如何协同工作?

在node.js中,我无法让superagent和nock一起工作。如果我使用请求而不是super代理,它会完美运行。这是一个简单的例子,superagent无法报告模拟数据:varagent=require('superagent');varnock=require('nock');nock('http://thefabric.com').get('/testapi.html').reply(200,{yes:'itworks!'});agent.get('http://thefabric.com/testapi.html').end(function(res){console.lo

node.js - 如何将 cookie 与 superagent 一起使用?

我正在使用express进行cookiesession管理,如下所示:req.session.authentication=auth;我使用类似的方式验证经过身份验证的网址if(!req.session.authentication){res.send(401);}现在我正在使用mocha为URL构建测试,superagent和should,但是我似乎找不到使用superagent获取/设置cookie的方法。我什至尝试在经过身份验证的测试之前请求登录,但它不起作用,我已经尝试在mochaBDD套件的before语句中将请求添加到登录名,但是它仍然告诉我该请求是未经授权的,我已经测试了

node.js - 如何使用 superagent/supertest 链接 http 调用?

我正在用supertest测试一个expressAPI。我无法在一个测试用例中获得多个请求来使用supertest。以下是我在测试用例中尝试过的。但是测试用例似乎只执行最后一个调用,即HTTPGET。it('shouldrespondtoGETwithaddeditems',function(done){varagent=request(app);agent.post('/player').type('json').send({name:"Messi"});agent.post('/player').type('json').send({name:"Maradona"});agent.
12