My response body is the array below every ten minutes in the last 24 hours, only the first two are shown below. I would like to test each for lossPercent < 5, latencyMs < 100, and jitter < 10
[
{
âstartTsâ: â2022-03-25T19:52:00Zâ,
âendTsâ: â2022-03-25T19:53:00Zâ,
âlossPercentâ: 0,
âlatencyMsâ: 3.93,
âgoodputâ: 100000,
âjitterâ: 0.07
},
{
âstartTsâ: â2022-03-25T19:53:00Zâ,
âendTsâ: â2022-03-25T19:54:00Zâ,
âlossPercentâ: 0,
âlatencyMsâ: 3.91,
âgoodputâ: 100000,
âjitterâ: 0.07
},
The problem is, when I run the test below it always passes, even if the data is above the threshold Iâve set, as you can see Iâve set âlatencyMsâ to be below 1, and it passes. Also, Iâm not sure itâs even looping through each array?
var response = JSON.parse(responseBody);
pm.test(âLatency is less than 100MSâ, () => {
_.each(pm.response.json().latencyMs, (arrItem) => {
pm.expect(arrItem.latencyMs.value).to.be.below(1)
})
});
pm.test(âLoss percentage is less than 5â, () => {
_.each(pm.response.json().lossPercent, (arrItem) => {
pm.expect(arrItem.lossPercent.value).to.be.below(5)
})
});
pm.test(âJitter is less than 10MSâ, () => {
_.each(pm.response.json().jitter, (arrItem) => {
pm.expect(arrItem.jitter.value).to.be.below(10)
})
});
I have a working test but it doesnât loop, it only tests against the first array
var response = JSON.parse(responseBody);
pm.test(âLoss percentage is less than 5â,function () {
pm.expect(.get(response, â0.lossPercentâ)).to.be.below(5);
});
pm.test(âLatency in MS is less than 100â,function () {
pm.expect(.get(response, â0.latencyMsâ)).to.be.below(100);
});
pm.test(âJitter is below 10MSâ,function () {
pm.expect(_.get(response, â0.jitterâ)).to.be.below(10);
});
Any help would be much appcreiated, thanks in advance