Unable to execute if statement in postman
Unable to execute if statement in postman
i've created below the test script, the goal is to validate response body to tests. but my problem is everytime i send request there's no test response. thanks in advance
if (pm.response.text() === "length must not be less than 3")
pm.test("length must not be less than 3", function ()
pm.expect(pm.response.text()).to.include("length must not be less than 3");
);
else if (pm.response.text() === "Record already exists.")
pm.test("Record already exists.", function ()
pm.expect(pm.response.text()).to.include("Record already exists.");
);
else if (pm.response.text() === "Username already exists.")
pm.test("Username already exists.", function ()
pm.expect(pm.response.text()).to.include("Username already exists.");
);
else if (pm.response.text() === "success")
pm.test("success", function (text)
pm.expect(pm.response.text()).to.include("success");
);
else
pm.test("Invalid Token", function ()
pm.expect(pm.response.jsonData()).to.include("Failed to connect.");
);
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Comments
Post a Comment