In the result at console we can see that fucntion was executed as utils.name=Kate. But at the same time no console.log output from update_name function was printed and collectionVariable was not updated.
Thank you,
I still don’t understand why it’s manadatory to pass pm if it’s global. Also actually getting value of collection variables pm.collectionVariables.get works fine in this function, but updates doesn’t.
And why the console.log in this function doesn’t work?
It’s obviously finding the function, as the function itself works ok.
It just won’t console log anything back.
I’ve tried defining a global variable (the usual way of doing this).
I’ve tried using object prototype, but that has the same issue.
I’ve even tried eval, which was the old way of doing this.
If I put the function into the Tests tab. Then it console logs as you would expect.
But when you put the function into the pre-request script where it belongs, it doesn’t error, but doesn’t console log either. The functions do work though (if they aren’t just console logging). The collection variables do get created.
If I console log the function name, I can see that Postman can see the functions inside.
I’m wondering if this is a new bug.
Fairly certain this used to work, and if you look at other examples on Stack Overflow, they have plenty of examples using console.log.
I don’t use this a lot, so don’t know when it broke.