Skip to content

Instantly share code, notes, and snippets.

@vdespa
Created April 11, 2018 11:16
Show Gist options
  • Save vdespa/0b3a8f469212cd516d5166360dbee717 to your computer and use it in GitHub Desktop.
Save vdespa/0b3a8f469212cd516d5166360dbee717 to your computer and use it in GitHub Desktop.
const newman = require('newman'),
fs = require('fs');
newman.run({
collection: require('./postman_collection.json'),
reporters: 'cli'
}).on('beforeRequest', function (error, args) {
if (error) {
console.error(error);
} else {
fs.writeFile(`request.txt`, args.request.body.raw, function (error) {
if (error) {
console.error(error);
}
});
}
}).on('request', function (error, args) {
if (error) {
console.error(error);
}
else {
fs.writeFile(`response.txt`, args.response.stream, function (error) {
if (error) {
console.error(error);
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment