{
"data": {
"notifications": [
{
"deeplink": "/users/1628507341",
"viewed": false
}
]
},
"status": "success"
}
how do I write Postman tests to verify the deeplink results like below.
I already know the deeplink ID, I want to combine with the string "users"
pm.test("notification deeplink is correct", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.data.notifications[0].deeplink).to.eql("/users/" + {{deeplink}});
});
You can use pm.variables.get("variable_name")
to get value from variable in Postman script
let deeplink = pm.variables.get("deeplink");
pm.test("notification deeplink is correct", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.data.notifications[0].deeplink).to.eql("/users/" + deeplink);
});