It looks to me, the id im trying to use is not ready from application side, but I do want to make sure it is indeed the application. Statuscode checks all seem passed. However I can’t seem to log it properly to make sure what statuscode it returns(in the console).
Is it possible when a typeError occurs, to add it into the final results overview?
What would be your recommended approach in this case?
Could you please post an example of a script (anonymized) that illustrates the error scenario you’re describing, it would be really hard for me to help you in a productive manner otherwise
Thanks a lot for posting your example script That’s really helpful!
You seem to be accessing 'id' in a variety of places, have you been able to isolate which of those throw a TypeError?
The json() method of HTTP Response returns either an Object or an Array, thus what k6 is reporting here, is a JS error happening because you’re trying to access the id property on a value that is undefined. From what I see in your code, that means that in the case of getMetaPropertyToValidateOption.json()['options'][0]['id'] for instance, it could be that the result of getMetaPropertyToValidateOption.json()['options'][0] is undefined (thus likely either options is undefined in your response’s body, or the array is empty and does not have an index [0]).
To track where the error happens, I would wrap every call you make which tries to access ['id'] with a try/catch block printing a dedicated message to the terminal, to find out what happens:
try {
optionId = getMetaPropertyToValidateOption.json()['options'][0]['id']
} catch (err) {
console.log(`unable to get meta property to validate option, reason: ${JSON.stringify(err)}, with body ${JSON.stringify(getMetaPropertyToValidateOption.json()}}`