Wait for PDF data to display

I have a request where we have to check if PDF is getting generated. The problem is that, request takes over 25 seconds to execute. When running manually, the request passes. But if I automate it for schedule run, it fails. I also tried adding an explicit wait, but it still fails. This is the code for wait:

pm.test("Wait for 25 seconds before proceeding with the test execution", function () {
    return new Promise(resolve => {
        setTimeout(resolve, 25000);
    });
});

Here is the PDF verification test after the wait:

pm.test("Verify PDF is generated", function () {
    pm.expect(pm.response.headers.get("Content-Type")).to.include("application/pdf");
});

Is there a way I can wait for data to display in the response and it works (Because currently it is not working)?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.