Sai Ram Reddy
Sai Ram Reddy

Reputation: 1089

How to Compare Response with value in postman Test cases

I have made a get request in postman which will return some response. I would like to compare that response has the value > 0 in test cases.

My current code is

  pm.test("Your test name", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.default_project_id) > 10
  });

Thanks in advance

Upvotes: 0

Views: 4556

Answers (1)

Suichi
Suichi

Reputation: 21

In the test section you can use the assert nodeJS module:

var assert = require('assert');

pm.test("The default ID > 10", function () {
    assert(jsonData.default_project_id > 10);
});

keep in mind that the default_project_id should be a number

Upvotes: 2

Related Questions