Quantcast
Viewing latest article 3
Browse Latest Browse All 3

Postman API testing: Unable to assert a value is true

I am testing an API with a GET request that returns the following data:

    {"Verified": true,"VerifiedDate": 2018-10-08}

I am trying to test that the first field comes back true, and the second field has a value. I have the following code:

    pm.test("Verified should be true", function () {   var Status = pm.response.json();   pm.expect(Status.Verified).to.be.true;});    pm.test("Returns a verified date", function () {   var Status = pm.response.json();   pm.expect(Status.VerifiedDate).to.not.eql(null);});

The assert on true is failing for the following reason:

Verified should be true | AssertionError: expected undefined to be true

Why is the first test failing?

I am running the same test on a post command without any issues.

Any ideas?

thanks


Viewing latest article 3
Browse Latest Browse All 3

Trending Articles