Brief Comparison of Responses in Postman

Moreover, if you don’t need to look for differences and just want to get YES (they are the same) or NO (they are not) — Postman is a way to do that.

Let’s assume that you have a REST API with success code = 200 OK (I took for example one handler of SpaceX REST API) and the response comes in JSON format.

GET https://api.spacexdata.com/v4/capsules/{capsuleId}

For the first request in the Test tab you need:

  • Save response data into a variable.
pm.test("Status is OK", function () {    pm.response.to.have.status(200);});let jsonData = pm.response.json();pm.globals.set("response", jsonData);

For the second request in the Test tab you need:

  • Get previous response data from a variable;
  • Compare current response data with the previous one. I use deep-eql Chai assert for comparing objects.
pm.test("Status is OK", function () {    pm.response.to.have.status(200);});let jsonData = pm.response.json();let firstResponse = pm.globals.get("response");pm.test("Responses are equal", function () {    pm.expect(jsonData).to.deep.equal(firstResponse);});

In the case of a FAIL test you have two different data.

For more detailed research of the cause of the failure or the place of data discrepancy you’ll need a more advanced test script or a different tool.

--

--

--

Quality assurance engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

My Pandoc Markdown-PDF Workflow for Routine, Not Especially Technical Writing

Simple Study Tips that I’ve learned

Fundamentals of Cloud Cost Management

OWASP-LPU CTF: Who Is There? -2

What’s the difference between git fetch and git pull?

Trading Strategy that Aims to Capture Overnight Moves

How to pass coding job exercises?

KYVE Network TESTNET guide

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrey Enin

Andrey Enin

Quality assurance engineer

More from Medium

Read request header values using Groovy Script on SoapUI/ReadyAPI

Write First Selenium-Cloud Test with Sauce Labs

How to make application test using Appium and Serenity BDD Screenplay?

Automated Testing Charts in Selenium WebDriver