Last active
April 29, 2019 07:42
-
-
Save victor-falcon/57b67ce16e56c54f3a5ef57ba5324616 to your computer and use it in GitHub Desktop.
Test that a response equals a desire JSON in Postman
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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