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