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 ![]()
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.