I am running multiple collections in NodeJs via postman,I am trying to share the clientHandshakeToken variable set in the first collection across multiple Postman collections using Newman but when second collection runs, it doesn't get the values of first collection instead, it takes the initial value
const newman = require('newman');
const collections = [
'./IndividualCollection/SignIn.postman_collection.json',
'./IndividualCollection/WorkSpace.postman_collection.json',
];
const environmentFile = './FeatureTesting_Variables.postman_environment.json'
collections.forEach((collections) => {
newman.run( {
collection: collections,
environment: environmentFile,
reporters: ['cli', 'htmlextra', 'json'],
reporter: {
},
color: 'auto', // For colored output
})
})
I tried by assigning the clientHandshakeToken as global variable , but I am unable to achieve it since when second collection run, it isn't taking the global variable, instead it is taking the initial value from the environment variable.
I found the solution by making the asynchronous code synchronous: