Postman test check status from endpoint https://reqres.in/api/users the status response is OK and have status code 201
//Postman test check status is 201 OK pm.test("The endpoint must be give respon code : 201", () => { const expectedStatusCode = 201; pm.response.to.have.status(expectedStatusCode); });Postman test check status from endpoint https://reqres.in/api/users 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 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(data)).to.include("name"); pm.expect(pm.response.text(data)).to.include("job"); pm.expect(pm.response.text(data)).to.include("id"); pm.expect(pm.response.text(data)).to.include("createdAt"); });Postman test check status of endpoint https://reqres.in/api/users 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 = 1000; 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 ); });
