Skip to content

Instantly share code, notes, and snippets.

@victor-falcon
Last active April 29, 2019 07:42
Show Gist options
  • Save victor-falcon/57b67ce16e56c54f3a5ef57ba5324616 to your computer and use it in GitHub Desktop.
Save victor-falcon/57b67ce16e56c54f3a5ef57ba5324616 to your computer and use it in GitHub Desktop.
Test that a response equals a desire JSON in Postman
pm.test("Equals response", function () {
const expectedJson = {};
const response = JSON.stringify(expectedJson);
try {
const data = pm.response.json();
pm.expect(JSON.stringify(data)).to.eql(response);
} catch(e) {
const data = pm.response.text();
pm.expect(data).to.eql(response);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment