Postman tests: checking responses with pm.test, examples and running a collection
Checkcraft is a desktop app for checking APIs and logs without code, with a free edition. Download, no sign-up →
A Postman test is a script that runs after the response and checks it. Tests go on the Scripts tab, Post-response section, in JavaScript with the pm object. The most common mistake is checking only status 200: such a test stays green when the data is wrong. Below are checks that catch real bugs.
Where to write tests
Open the request, the Scripts tab and the Post-response section. In older Postman versions this tab was called Tests. Snippets on the right insert templates such as a status check, but you must add your own fields and expectations.
What to check besides status
Required fields, their types, allowed status values, calculations such as a discounted total, field relations and the absence of extra data like password hashes. A good trick: break the expected value and make sure the test goes red. If it does not, it checks nothing.

Running in bulk
The Collection Runner runs all requests of a collection in order and shows failing tests. For CI use the Postman CLI or Newman. Note that the Postman free plan is now for a single user.
Ready response tests
pm.test("статус 201", () => pm.response.to.have.status(201));
const order = pm.response.json();
pm.test("есть номер заказа", () => {
pm.expect(order.id).to.be.a("number");
});
pm.test("итог = сумма позиций минус скидка", () => {
const subtotal = order.items.reduce((s, i) => s + i.qty * i.price, 0);
pm.expect(order.total).to.eql(subtotal - order.discount);
});
pm.test("статус из допустимого списка", () => {
pm.expect(["NEW", "PAID", "SHIPPED", "CANCELLED"]).to.include(order.status);
});
pm.test("нет лишних полей с секретами", () => {
pm.expect(order).to.not.have.property("passwordHash");
});
pm.test("ответ быстрее 800 мс", () => pm.expect(pm.response.responseTime).to.be.below(800));
// сохранить id для следующего запроса цепочки
pm.collectionVariables.set("orderId", order.id);Each pm.test is reported separately, so a failure shows exactly what broke. The last line saves the order id for the next chained request: request chains.

Weak vs strong checks
| Weak check | What it misses | Strong check |
|---|---|---|
| status 200 | Wrong data | status + fields + calculations |
| total exists | Wrong amount | total = items sum − discount |
| status not empty | Typo PAYED | status from the documented list |
| response not empty | Leaked passwordHash | no fields outside the contract |
If an AI wrote the tests, review them: they often only check that a response arrived. See empty AI tests.
More on Postman
Section overview and all guides: Postman requests: how to send GET, POST, PUT and DELETE with examples.
- Postman variables: environments, collections and passing a token
- How to save a collection and a request in Postman: Save, History and a file
- How to import cURL into Postman: paste the command and get a ready request
- Postman errors 401, 403, 405 and 415: what they mean and how to fix them
- Postman collection audit: how many requests have no checks
Frequently asked questions
Where do Postman tests go?
Scripts → Post-response (formerly the Tests tab).
How do I check a JSON field?
pm.response.json() and pm.expect inside pm.test.
How do I run all tests?
Collection Runner, Postman CLI or Newman.
Repeat this on your own API
Checkcraft is a desktop app that saves API response checks without code and shows what did not match. Start with a sample, then use your own sanitized data. Free runs on Windows and Linux with no time limit.
Download FreeDownload and first runNo sign-up or email needed, the archive is ready in a couple of minutes. See the edition limits.
References
Start with the linked example and compare its result with your own test requirement.