jeudi 24 janvier 2019

POSTMAN - Test failure false to be truthy

As a beginner I have few questions. I am using the Get request, which would populate json below.

https://reqres.in/api/users

{
    "total": 12,
    "total_pages": 4,
    "data": [{
        "id": 1,
        "first_name": "George",
        "last_name": "Bluth",
        "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/calebogden/128.jpg"
    }]
}

for the 2 tests below while the 1st one passes the 2nd test fails with the message:

 AssertionError: expected false to be truthy

    //Verify Page number total is 12
    var jsonData = JSON.parse(responseBody);
    tests["Checking total page number-Manual"] = jsonData.total === 12;

    //verify is exists and is 1
    var jsonData = JSON.parse(responseBody);
    tests["Checking ID exists and is 1"] = jsonData.id === 1;

Question 1: A github post that I found says there may be an error and suggests to use the new pm.* equivalent instead. However I do not see any difference between the 1st and the 2nd. So why does the 2nd test fail?

Question 2: Is it possible to write test to verify that for ID:1 the firstname is George?

Thanks in advance for your time.

Aucun commentaire:

Enregistrer un commentaire