Skip to content

Instantly share code, notes, and snippets.

@ryanthegiantlion
Last active January 30, 2019 12:17
Show Gist options
  • Save ryanthegiantlion/237ba222644c0f70409793c79b3dffbf to your computer and use it in GitHub Desktop.
Save ryanthegiantlion/237ba222644c0f70409793c79b3dffbf to your computer and use it in GitHub Desktop.
postman test cheat sheet

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;

  • Http codes tests["Successful POST request"] = responseCode.code === 201 || responseCode.code === 202;

  • env variables pm.environment.set("auth_header", "Bearer " + data.data.login); and pm.environment.get

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment