I am currently using newman as my runner and I have this javascript file which handles bunch of events to be triggered during the execution.
I am executing a collection which I exported from postman. I am having a problem wherein I used an event 'beforeTest' which I expect to run before every test script (sub-folder in postman) but what happens is that it run before every http request.
Here is a sample code from my js file runner.
newman.run({
collection: "myCollection.json",
environment: "myEnvironment.json",
globals: "",
reporters: ['json','html','cli'],
reporter: {}
}).on('beforeTest', function (err, args) { //before test run
//Run some code here
//Expected: Since I used 'beforeTest' I expect that this code will be triggered before each testscript
//Actual: This code was triggered before each http request
}).on('start', function (err, args) { // on start of run, log to console
//Run Testscript here
}).on('done', function (err, summary) {
//Run some code here
});
Is there a way wherein the event 'beforeTest' will only run before each testscript? did I miss anything or I am doing something wrong? I appreciate any help Thanks!