Have variable name {{userName}} which i capture in pre-script as pm.environment.get("userName");
The printing works fine but Assertion error
pm.test("Check For legal name", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.Detail.legalName).to.eql(pm.environment.get("userName"));
});
but gives Assertion error as
AssertionError: expected undefined to deeply equal āTest Firsnameā
What is the syntax to make this test pass. @danny-dainton
Well Said its ok ā¦also verify with wrong test using surnameā¦ it fails so OK now and Sorry i tagged youā¦ since you always answers first, reason for tagging you.
@gpub1 Good Afternoon, I just want to know how you capture username in the environment variable using pre-script. I am new in Postman so I want to know your way.
I would recommend going through the Postman training first, as most of these elements are covered and it will give you an understanding when you read other users solutions.
This is potentially covered in the Learning Centre.