Postman test check status from endpoint https://reqres.in/api/users?page=2 the status response is OK and have status code 200
//Postman test check status is 200 OK pm.test("The endpoint must be give respon code : 200", () => { const expectedStatusCode = 200; pm.response.to.have.status(expectedStatusCode); });Postman test check status from endpoint https://reqres.in/api/users?page=2 the status not have status code 404 or 500
//Postman test check status untuk mengecek apakah terdapat status code 404 atau 500 pm.test("the endpoint does not return unexpected status code : 404 or 500", () =>{ const unexpectedStatusCodes = [404, 500]; pm.expect(pm.response.code).to.not.be.oneOf( unexpectedStatusCodes, did not expect response status to be one of ${unexpectedStatusCodes} but got ${pm.response.code}. ); });Postman test check status of endpoint https://reqres.in/api/users?page=2 to check response in the body in field section
//Postman check untuk check respon di body pm.test("Verify value in respon body", function(){ pm.expect(pm.response.text()).to.include("data"); pm.expect(pm.response.text(data)).to.include("id"); pm.expect(pm.response.text(data)).to.include("email"); pm.expect(pm.response.text(data)).to.include("first_name"); pm.expect(pm.response.text(data)).to.include("last_name"); pm.expect(pm.response.text(data)).to.include("avatar"); pm.expect(pm.response.text(data)).to.include("url"); pm.expect(pm.response.text(data)).to.include("text"); });Postman test check status of endpoint https://reqres.in/api/users?page=2 to check response in the value in each fields
//Postman check response the value in each fields pm.test("API response contains the expected fields", function () { const response = pm.response.json() pm.expect(response).to.have.nested.property("data.id", 9); pm.expect(response).to.have.nested.property("data.email", "[email protected]"); pm.expect(response).to.have.nested.property("data.first_name", "Tobias"); pm.expect(response).to.have.nested.property("data.last_name", "Funke"); pm.expect(response).to.have.nested.property("data.avatar", "<https://reqres.in/img/faces/9-image.jpg>"); pm.expect(response).to.have.nested.property("support.url", "<https://reqres.in/#support-heading>"); pm.expect(response).to.have.nested.property("support.text", "To keep ReqRes free, contributions towards server costs are appreciated!"); });Postman test check status of endpoint https://reqres.in/api/users?page=2 to check expected timeout threshold
//Postman test check status untuk mengetahui respon dalam waktu yang diharapkan pm.test("Response time is expected treshold", () => { const expectedTime = 100; pm.expect(pm.response.responseTime).to.be.lessThan( expectedTime + 1, The endpoint did not respond within ${expectedTime} ms. Respon come in ${pm.response.responseTime} ms ); });

