Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nilsandrey/2905657651be064ad6a8c44542c7d668 to your computer and use it in GitHub Desktop.
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.
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