我正在用supertest测试一个express API.
我无法在一个测试用例中获得多个请求来使用supertest.下面是我在测试用例中try 的内容.但测试用例似乎只执行最后一个调用,即HTTP GET.
it('should respond to GET with added items', function(done) {
var agent = request(app);
agent.post('/player').type('json').send({name:"Messi"});
agent.post('/player').type('json').send({name:"Maradona"});
agent.get('/player').set("Accept", "application/json")
.expect(200)
.end(function(err, res) {
res.body.should.have.property('items').with.lengthOf(2);
done();
});
);
我在这里遗漏了什么,或者有没有其他方法可以将http调用与superagent链接起来?