I am trying to test a response from a server. Suppose the response is an array whose elements have a set of properties and the corresponding values are objects having other properties.
For example something like:
{
"array": [
{
"porp1": {
"subprop11": "a",
"subprop12": [1,2]
},
"prop2": "c",
},
{
"porp1": {
"subprop11": "h",
"subprop12": [3,2]
},
"prop2": "a",
}
]
}
I want check all the elements of the arrays to have the properties and sub-properties. For the first level properties I managed to do that using chai-things
:
const chai = require('chai');
chai.use(require('chai-things'));
....
res.body['array'].should.all.have.property('prop1');
res.body['array'].should.all.have.property("prop2");
How can I check the elements to have the subproperties "subprop11"
and `"subprop12"?
Aucun commentaire:
Enregistrer un commentaire