Hi
I am using pm. sendRequest() inside two test functions.
Working Snippet
transferinsufficientbalance()
function transferinsufficientbalance() {
const expression =
pm.globals.get(âidempotentâ);
eval(expression);
const req = {
url: pm.environment.get(âurlâ) + '//v1/â,
method: âPOSTâ,
header: {âpsmUserIDâ:'â
},
body: {
mode: ârawâ,
raw: JSON.stringify({ âfromâ:{âpsmUserIDâ: "", âuseDefaultâ:true ,ânetworkâ:âstellarâ},âtoâ:{âpsmUserIDâ:"",âuseDefaultâ:true,ânetworkâ:âstellarâ},âsizeâ:â100000â,âassetIDâ:"*****",âidempotentIDâ:pm.globals.get(âidempotentIDâ)})
}
};
pm.sendRequest(req, function (err, res) {
console.log(err ? err : res.json());
pm.test(âValidate whether sender doesnt have enough balanceâ, function () {
if (res.code == 200) {
pm.expect(res.json().status.type).to.eql("failed");
pm.expect(res.json().status.errorCode).to.eql(1007);
pm.expect(res.json().status.errorMessage).to.eql("The sender doesn't have enough balance");
}
else {
pm.expect(res).to.have.property('code', 200);
}
});
});
}
// 3.To Validate whether account is present for the given psmUserID
accountpresentinuserid()
function accountpresentinuserid() {
const expression =
pm.globals.get(âidempotentâ);
eval(expression);
const req = {
url: pm.environment.get(âurlâ) + '//v1/â,
method: âPOSTâ,
header: {âpsmUserIDâ:'â
},
body: {
mode: ârawâ,
raw: JSON.stringify({ âfromâ:{âpsmUserIDâ: "", âuseDefaultâ:false,âaccountIDâ:â123â ,ânetworkâ:âstellarâ},âtoâ:{âpsmUserIDâ:"",âuseDefaultâ:false,âaccountIDâ:â000â,ânetworkâ:âstellarâ},âsizeâ:â1â,âassetIDâ:"**",âidempotentIDâ:pm.globals.get(âidempotentIDâ)})
}
};
pm.sendRequest(req, function (err, res) {
console.log(err ? err : res.json());
pm.test("Validate whether account is present for the given psmUserID", function () {
if (res.code == 422) {
console.log(res.json());
pm.expect(res.json().errorCode).to.eql(1010);
pm.expect(res.json().errorMessage).to.eql("Sender's blockchain account not found");
}
else {
pm.expect(res).to.have.property('code', 422);
}
}
});
}
Now i am facing the issue of pm.sendRequest() not running in one after other.
Can i know how to give explicit wait time inbetween the request