Junior — Middle
Have you created automated tests for APIs using Postman?
sobes.tech AI
Answer from AI
Yes, in Postman, you can create automated tests for APIs using the built-in scripting language based on JavaScript. Usually, tests are written in the "Tests" tab of each request, where you can check the response status, body content, headers, and other parameters.
Example of a simple test in Postman:
pm.test("Response status is 200", function () {
pm.response.to.have.status(200);
});
pm.test("Response contains the user's name", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.name).to.eql("Ivan");
});
You can also create request collections with tests and run them automatically via Collection Runner or integrate with CI/CD systems using Newman — a command-line tool for running Postman collections.