I'm creating API test which checks that the response contains specific key "textId" in structure:
it('TC-4 /rest/passwords/ should change "password"', function() {
return chai.request(serverurl)
.post('/rest/passwords/')
.set('Content-Type', 'application/json')
.set('Accept', 'text/html')
.set('X-Api-Key', global.apikey)
.set('Cookie', global.cookie)
.send({password: "password"})
.then(function(res) {
res.should.have.status(200);
res.should.be.json;
console.log('TC-4 /rest/passwords/: %j\n', res.body);
res.body.should.have.all.keys(['textId']);
});
});
response is following:
[{"textId":"PasswordNeedsAtLeastOneDigit","parameters":{}},{"textId":"PasswordNeedsAtLeastOneUpperCaseCharacter","parameters":{}}]
I tried:
res.body.should.have.property('textId');
res.body.should.have.nested.property('textId');
res.body.should.have.all.keys(['textId']);
res.body.should.have.all.nested.keys(['textId']);
none of them works