Created
March 28, 2025 17:13
-
-
Save nilsandrey/2905657651be064ad6a8c44542c7d668 to your computer and use it in GitHub Desktop.
Response Time postman tests with retry option before failing. Useful for warming-up-needed scenarios.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pm.test("Response time is less than 1 second, retries up to 3 times", function () { | |
pm.expect(pm.response.responseTime).to.be.below(1000, "Response time should be less than 1 second"); | |
let retries = 0; | |
while (pm.response.responseTime >= 1000 && retries < 3) { | |
pm.sendRequest(pm.request, function () { | |
pm.expect(pm.response.responseTime).to.be.below(1000, "Response time should be less than 1 second"); | |
}); | |
retries++; | |
} | |
pm.expect(pm.response.responseTime).to.be.below(1000, "Response time should be less than 1 second after retries"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment