I need to know how should be the script to know if time is duplicated
[
{
"time": "2020-09-29T00:00:00Z"
},
{
"time": "2020-09-30T00:00:00Z"
},
{
"time": "2020-09-30T00:00:00Z"
},
{
"time": "2020-10-01T00:00:00Z"
},
{
"time": "2020-10-01T00:00:00Z"
}
]
i did it like this but the test is passing and should fail
pm.test("time is not duplicate ", function () {
var jsonData = pm.response.json();
let result = jsonData.reduce(function (arreglo, item) {
let isDuplicate = arreglo.some(function (jsonData) {
let condition = jsonData.time === item.time;
return condition;
});
if (isDuplicate) {
arreglo.push(item);
}
return arreglo;
}, []);
let hasDuplicates = result.length > 0;
pm.expect(hasDuplicates).to.be.eql(false);
});