Я тестирую экспресс-API с supertest.
Я не мог получить несколько запросов в тестовом примере для работы с супертестом. Ниже я попытался в тестовом примере. Но тестовый пример, похоже, выполняет только последний вызов, который является 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-звонки с суперагентом?