Skip to content
CodeKruPro

Write a Postman test for the status and a field

QuizEasy-MediumAsked in: Capgemini, Infosys

Which Postman test script correctly checks that the response status is 201 and that the JSON body has email equal to asha@example.com?

  • pm.test("created", function () { pm.response.to.have.status(201); pm.expect(pm.response.json().email).to.eql("asha@example.com"); });
  • pm.assert(201); pm.assert(email == "asha@example.com");
  • if (status == 201) { console.log("pass"); }
  • pm.test("created", pm.response.status === 201);

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in