Postman CLI - pm.response.json() - not working with bigger payloads?

Hi All.

Has any else experienced the same issue as me I have a test in postman that, get the repsonse and converts it to JSON, but when I try to use the variable, it doesn’t exist on CLI, but does within Postman CLI :frowning:

I don’t know if it’s a timing thing or what, as the response body is about 5K.

I tried wrapping it with setTimeout, but the CLI ignored that. Only the Postman client works.

This is my code:

       const responseJson = pm.response.json();
       const totalShipments = responseJson.included.length;


        pm.test(`${totalShipments} shipments on the route`, () => {
            pm.expect(totalShipments).to.be.at.least(0);

        });

It fails with this error:
Error parsing response: TypeError: Cannot read properties of undefined (reading ‘length’)

Would anyone have an idea on a way to work around this issue, please? As I say, it works fine in the Postman Client; it’s just CLI.

Thanks in advance.

Seems like its not the payload that the issue, I can console.log the payload out.

This line is throwing the error.
const totalShipments = responseJson.included.length;