How to define max response time - for test

Test server request limitation

Is there any way to set max response time?

For example - if you want to test if the server don’t answer after a fixed number of inquiries.

I want to define it in a test. Best without Javascript settimeout.

Hey @flippiflappi :wave:

Could you clarify the question more and add more context, please?

There are checks that you can do against the response time, for a set value you would like it be be below, above, within etc.

pm.test("Response time is less than 200ms", function () {
    pm.expect(pm.response.responseTime).to.be.below(200);
});
pm.test("Response time is more than 200ms", function () {
    pm.expect(pm.response.responseTime).to.be.above(200);
});
pm.test("Response time is with 200ms and 500ms", function () {
    pm.expect(pm.response.responseTime).to.be.within(200, 500);
});

It’s not about testing how long the response was.
If the response takes too long, you should start doing something. So say, max response so long - do that …
→ max response time for pm.sendRequest

Without more extensive details of what you are trying to do - The only solution that people will be able to offer is just guessing what you’re trying to achieve.

I would suggest looking through this guide and editing the original question and provide all the details.

I’ve tried to use this and it seems it will still wait for the response of the API before failing the test? Is there a way like if it reach the limit it will already fail the test? Or still it will need to rely on the response being completed?