Postman has released an update that allows users to set Collection Variables in the Pre-Request scripts. I have been using this new functionality in my Collection and it has successfully worked. When adding this collection to Jenkins, the job fails because Newman does not handle setting Collection Variables in the Pre-Request script.
For example, my Pre-Request script looks like this:
// username and email use sysdate + “@mailinator.com”
const date = new Date();
partialUsername = date.getTime();
const username = “cubic” + partialUsername;
partialEmail = date.getTime();
const email = “cubicTest” + partialEmail + “@mailinator.com”;
pm.collectionVariables.set(‘username’, username);
pm.collectionVariables.set(‘email’, email);
In Jenkins, the error I am seeing is:
failure detail
- TypeError
Cannot read property ‘set’ of undefined
at prerequest-script
inside “C2456099 - Create Account / Create Account”
Looks like Newman needs an update to allow this new functionality released by Postman.
Anyone have any ideas when that would be?