Untitled
unknown
plain_text
a year ago
783 B
1
Indexable
Never
const currentTiming = pm.response.responseTime; let totalTiming = pm.globals.get("timings"); let array; // If postman variable is empty it is an empty string if (totalTiming.length === 0) { // This is the case for the first or single request totalTiming = currentTiming; array = [totalTiming]; } else { totalTiming = `${totalTiming},${currentTiming}`; array = totalTiming.split(','); } pm.globals.set("timings", totalTiming); let sumOfArray = 0; for (let i = 0; i < array.length; i++) { sumOfArray += Number(array[i]); } const average = sumOfArray / (array.length); pm.test(`Response timings: Average = ${average.toFixed(2)}, Max = ${Math.max(...array)}, Min = ${Math.min(...array)}`, function () { pm.expect(pm.response.responseTime).to.be.above(0); });