Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Save common tests in a global variable
- postman.setGlobalVariable("commonTests", () => {
- // The Content-Type must be JSON
- tests["Content-Type header is set"] = postman.getResponseHeader("Content-Type") === "application/json";
- // The response time must be less than 500 milliseconds
- tests["Response time is acceptable"] = responseTime < 500;
- // The response body must include an "id" property
- var data = JSON.parse(responseBody);
- tests["Response has an ID"] = data.id !== undefined;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement