Export test result to a file

I have written a test and now I need to export the result to a file in my local disk.

I need to do that in the code itself. COuld anyone tell me how I can do that.

I need to save the respone c in a file

Hello @ereddy068 :slightly_smiling_face:

To do this action via code as you mentioned, then you would need Newman to do along. How are you running your Tests? Through collection runner or via Newman? Please share more details here.

Also please check the similar query raised and see if it helps.

1 Like

If you are running through a collection runner, then first need to check Save response. After it got executed. You can export the result
for newman you need use newman library run you need to use your paths

const newman = require('newman'),
      fs = require('fs')

newman.run({
  collection: '<Collection File>',
  environment: '<env path json file',
  iterationCount: 1

}).on('console', function (error, args) {
      fs.appendFileSync('./results.csv', args.messages, function (error) {
  })
})