← API Testing with Postman learning path
API Testing with Postman · Module 5 of 10

Writing tests in Postman

Add assertions to check responses automatically.

📖 Key ideas

  1. Tests are JavaScript in the Scripts → Post-response tab.
  2. pm.test("Status is 200", () => pm.response.to.have.status(200));
  3. Check JSON: const data = pm.response.json(); pm.expect(data.name).to.eql("Asha");
  4. Check response time: pm.expect(pm.response.responseTime).to.be.below(500);
  5. Snippets help write common tests quickly.
💡 Real-life example: Postman tests are a checklist ticked automatically after every delivery arrives.
pm.testDefines a test
pm.expectChai-style assertion
pm.response.json()Parses JSON body
SnippetReady-made test code