Test scripts
Anatomy of a test script
Section titled “Anatomy of a test script”pm.test("status is 200", () => pm.response.to.have.status(200))pm.test("response under 500ms", () => pm.expect(pm.response.responseTime).to.be.below(500))
const body = pm.response.json()pm.test("has user id", () => pm.expect(body.user).to.have.property("id"))pm.test("role is admin", () => pm.expect(body.user.role).to.equal("admin"))
// Persist for downstream requestspm.environment.set("userId", body.user.id)pm.log("captured userId:", body.user.id)Test results appear in the response Scripts panel with pass/fail counts. A pm.test in a pre-request script is reported too: it appears in the Pre-request block and counts in the collection runner, kurlo run and kurlo mcp.
Was this page helpful?