I have an API Endpoint that returns a JSON array in response:
[
{
"base": "ethereum-eth",
"quote": "tether-usdt",
"volume": 60126390.25608005,
"price": 1663.0597462528697,
"volumePercent": 32.36999258988893,
"spread": 0.006014675808968427,
"category": "Verified",
"time": 1659695310
},
]
I try to run the code below for each item of Array
pm.test("Check if response contains all the keys", function () {
var data = pm.response.json();
data.forEach(function(item) {
pm.expect(item).to.have.all.keys('base', 'qoute', 'volume', 'price', 'volumePercent', 'spread', 'category', 'time');
});
});
Response
Check if response contains all the keys | AssertionError: expected { base: 'ethereum-eth', …(7) } to have keys 'base', 'qoute', 'volume', 'price', 'volumePercent', 'spread', 'category', and 'time'
For some reason, even for one item, I have an Assertion error
pm.test("Check if response contains all the keys", function () {
var data = pm.response.json();
console.log(data[0]);
pm.expect(data[0]).to.have.all.keys('base', 'qoute', 'volume', 'price', 'volumePercent', 'spread', 'category', 'time');
});
How I can resolve it? pls, help