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