Various variables are made available by postman runtime and can be references in the test script. Common ones are responseCode
and responseBody
and responseTime
-
Parse response body
var data = JSON.parse(responseBody);
-
Test Format
tests["Test Name"] = {condition}
e.g tests["Has token"] = data.data.login != null; -
Response times
tests["Response time is less than 500ms"] = responseTime < 500;