Postman Script
Scripting
Before Request
var moment = require("moment");
(function(pm, moment, today, adultBithDateMin, adultBithDateMax){
adultBithDateMin = moment(today).subtract(18, 'years').add(1, 'days').format("DD/MM/YYYY");
adultBithDateMax = moment(today).subtract(66, 'years').format("DD/MM/YYYY");
pm.setEnvironmentVariable('adult.birth.date.min', adultBithDateMin);
pm.setEnvironmentVariable('adult.birth.date.max', adultBithDateMax);
console.info("Adult Min birth Date: " + adultBithDateMin);
console.info("Adult Max birth Date: " + adultBithDateMax);
}(postman, moment, new Date()));
After Request
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("quotationRefId", jsonData.refId);
pm.test("Successful Quotation", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.message).to.eql("Quotation has been created successfully.");
});
References
|